1

I want to convert a string into a hex using xxd.

The problem is that it adds a "0a" at the end of the hex.

Command:

echo "hello world" | xxd -p

Output: 68656c6c6f20776f726c640a

Expected: 68656c6c6f20776f726c64 (without the 0a)

1 Answers1

3

0x0a is the hex value of an ASCII newline.

echo produces a new line at the end, so you got trailing 0a.

To avoid this, use -n parameter:

echo -n "hello world" | xxd -p

Or, you can use printf:

printf "hello world" | xxd -p
cheack
  • 394
  • 1
  • 6