2

I'm trying to generate a string of 10 followed by a NULL (\0) followed by a 10.

However echo "10\010" does not seem to work (I'm guessing it generates two chars - a 10 followed by \010. I'm not sure how to separate / escape these values / characters?

I've also tried echo "10""/0""10" which had the same result.

I'm piping this output to a named pipe.

1 Answers1

2

In a POSIX compliant shell you could use:

echo '10\000010'

note that echo requires three octal numbers to follow a \0 to terminate an octal escape sequence.

The problem in your case is that bash is not POSIX compliant in this case as it does not implement XSI support that is required for a non-embedded UNIX variant.

bash however partially supports printf and so you could use:

printf '10\00010\n'
schily
  • 19,173