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


.



Relevant Pages

  • Re: Undeleting from a FAT partition
    ... the first characer of the ... filename was replaced by a null. ... is scan the data with a hex editor, looking for a likely array. ...
    (Debian-User)
  • Re: Changing the name of my computer
    ... find that filename~ is the prior version of filename. ... Programming without a hex editor is like watchmaking without a hammer. ... To UNSUBSCRIBE, email to debian-user-request@lists.debian.org ...
    (Debian-User)
  • Re: trailing blank line in a text file
    ... > Have you used a hex editor to really see what the file contains? ... > od -ha filename ... > will dump the contents of the file in hex with the ascii. ... But in the file where there's no trailing blank line (the one that I ...
    (Fedora)