Why od -c directory
Doesn't Work
A directory points to zero, one, or a bunch of files, it isn't really a file itself so it can't be processed by od
or hd
. Most Unix-like programs process files, not whole directories.
What to Do
You can list the contents of the directory with ls
and then use the od -c
or hd -b
command to dump each file you want to examine. By doing them one-by-one you will know what each file contains.
(od -c file1 file2
stuffs file1 and file2 together and then dumps the whole thing. That makes it heard to find where the first one ends and the next one begins.)
You could also write a little script to give you, one by one, the filename of each of the files in a directory and then dump it in octal or hex. Here's an example:
for f in *; do echo $f; od -c $f; done | less
for f in *
assigns each file in the current directory to $f in turn; echo $f
provides the name of the file on your terminal preceeding each file dump; od -c $f
produces the dump; and done
says to go on with the next file or finish if there aren't any more. |less
says take all of the above and send the output through the "less" program which let's you look at it bit by bit rather than having everything roll off the top of the screen.
A script like this is interpreted by a program called by a "shell". When you are typing commands into the terminal you are talking to a "shell". By default, Ubuntu uses the "bash" shell.
If you would rather look at hex output you can use od -t x1 filename
or hd filename
. Use man od
or man hd
for more options.