I am trying to write bytes to a file on my system in a script, and I decided to use xxd (with -r) to achieve this. However, I want it to take endianness into account for each 4 bytes. here is an example i used to test this:
echo "1122334455667788" | xxd -r -p -g 4 - outfile
I get the following output when i do hexdump outfile:
0000000 2211 4433 6655 8877
0000008
Because I used -g 4, I expect the result to be like this
0000000 4433 2211 8877 6655
0000008
It is not behaving like I expect it to. What am I doing wrong here?
EDIT:
I realise now that -g does is not supposed to change the byte ordering. However, xxd does take endianness into account as in the examples I provided. The question now is how can I get xxd to flip bytes in groups of 4 bytes (32-bit little endian values) instead of every 2 bytes to get the result I wanted? is this even possible with xxd alone?