Re: How do show (on cmdline/terminal) a (text) file content in hex format?




"Peter Hanke" <peter_ha@xxxxxxxxxx> schrieb im Newsbeitrag
news:4c45cc32$0$6888$9b4e6d93@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Assume I have a (text) file.
How can I print out this files content from cmdline/terminal as/with hex
values?

Again: No GUI based hex editor should be used.

The output should (if possible) show the real (huma readable) content in a
second
olumn and be something similar to (only one line sample):

61 6C 69 61 73 20 2E 2E 3D 27 63 64 20 2E 2E 27 alias ..='cd ..'

Peter


On some systems the 'xxd' tool can be found.

xxd -g 1 <filename>

BTW. For C programmers out there the '-i' option may be particularly useful.

xxd -i fileName

unsigned char filename[] = {
0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x72, 0x65, 0x0a
};
unsigned int filename_len = 12;


Ahh.. and the tool can also do the reverse:
echo "68656c6c6f2074686572650a" | xxd -r -p
hello there

--
Piotr


.