As the title says, here is an example:
$ cat test.txt
ABCD
$ hd test.txt
00000000 41 42 43 44 0a |ABCD.|
00000005
my desired output would be:
41
42
43
44
I know that this is possible with sed, awk and stuff, but this might be very slow for large files. I thought of an format string for "hexdump" or a parameter combination for "od". Could you please help me out?
$ echo -n 'ABCD' | hexdump -v -e '/1 "%02x\n"'
41
42
43
44
0a
If you don't want it to print 0a
at the end for the newline then I'd recommend getting rid of the newline from the file first.
od -An -vtx1 -w1 test.txt | cut -c2-
If you don't want newlines:
od -An -vtx1 -w1 test.txt | cut -c2- | fgrep -v 0a
Meaning of od
options:
-An
: addresses: no-v
: verbose, i.e., don't write a *
instead of repeating lines-tx1
: output type: hex, 1 byte (use -tx1z
for an hd
-like output)-w1
: max width: 1One nice thing about od
is that it's available on any *x
system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With