Skip to main content
edited tags
Link
Ole Tange
  • 37.6k
  • 34
  • 119
  • 228
Source Link
Sandburg
  • 359
  • 3
  • 13

How to avoid Bash printf error when printing certain hexa values: Input/output error

I'm using the command printf of bash on Ubuntu under WSL.

I'm trying to use this documented syntax

\xHH byte with hexadecimal value HH (1 to 2 digits)

This works for printf "\x0A" (carriage return) and many other values.

But does not work for printf "\xFF" or printf "\xFE" which I want to use to inject a BOM Utf-16 prefix before piping the content of a Utf-16 file (but without bom) to some treatment.

For this values (past 0xF8 included), I get the error:

-bash: printf: write error: Input/output error