hex

On Unix systems the od program can be used to display the hexadecimal content of files. I find the format of the od output difficult to read. So I have written hex.

The hex program displays the contents of a file in hexadecimal and ASCII. Execute hex as follows:

    hex [-h] [file...] 
The -h parameter displays help information. Parameters are the names of files to be displayed. If no filenames are given then the data is read from the program's standard input.

Example

sms> ls | hex
  00000: 43 56 53 0a 4d 61 6b 65 66 69 6c 65 0a 64 65 66  : CVS.Makefile.def
  00016: 69 6e 65 73 0a 64 65 66 69 6e 65 73 2e 6c 69 73  : ines.defines.lis
  00032: 74 0a 64 65 66 69 6e 65 73 2e 73 68 0a 65 72 72  : t.defines.sh.err
  00048: 6e 6f 0a 65 72 72 6e 6f 2e 63 0a 68 65 78 0a 68  : no.errno.c.hex.h
  00064: 65 78 2e 63 0a 73 69 6e 66 6f 2e 62 75 69 6c 64  : ex.c.sinfo.build
  00080: 0a 73 69 6e 66 6f 2e 62 75 69 6c 64 2e 73 68 0a  : .sinfo.build.sh.
  00096: 73 69 6e 66 6f 2e 63 0a 73 69 6e 66 6f 2e 6c 69  : sinfo.c.sinfo.li
  00112: 73 74 0a 73 69 7a 65 6f 66 0a 73 69 7a 65 6f 66  : st.sizeof.sizeof
  00128: 2e 63 0a 73 79 73 63 6f 6e 66 0a 73 79 73 63 6f  : .c.sysconf.sysco
  00144: 6e 66 2e 62 75 69 6c 64 0a 73 79 73 63 6f 6e 66  : nf.build.sysconf
  00160: 2e 62 75 69 6c 64 2e 73 68 0a 73 79 73 63 6f 6e  : .build.sh.syscon
  00176: 66 2e 63 0a 73 79 73 63 6f 6e 66 2e 69 6e 63 0a  : f.c.sysconf.inc.
  00192: 73 79 73 63 6f 6e 66 2e 6c 69 73 74 0a 74 65 6c  : sysconf.list.tel
  00208: 6c 74 69 6d 65 0a 74 65 6c 6c 74 69 6d 65 2e 63  : ltime.telltime.c
  00224: 0a 74 6f 6f 6c 73 2e 74 61 72 0a                 : .tools.tar.
sms>

hex.c

hex.c processes each file in turn, opening it and then reading its contents. If no files are specified then data is read from the standard input.

Home