I'm trying to do some tricks with dd. I thought it would be possible to store some hexvalues in a variable called "header" to pipe it into dd.
My first step without a variable was this:
$ echo -ne "\x36\xc9\xda\x00\xb4" |dd of=hex
$ hd hex
00000000 36 c9 da 00 b4 |6....|
00000005
After that I tried this:
$ header=$(echo -ne "\x36\xc9\xda\x00\xb4")
$ echo -n $header | hd
00000000 36 c9 da b4 |6...|
00000004
As you can see I lost my \x00
value in the $header
variable.
Does anyone have an explanation for this behavior? This is driving me crazy.
bash: warning: command substitution: ignored null byte in input
. – Kusalananda Feb 24 '17 at 17:29header="$(echo -ne "\x36\xc9\xda\x00\xb4")"; echo -n "$header" | hd
however this just gives same result. – ctrl-alt-delor Feb 24 '17 at 19:01header="\x36\xc9\xda\x00\xb4"; echo -n "$header" | hd
, but is not the same thing as it is storing the human readable form. – ctrl-alt-delor Feb 24 '17 at 19:03