# Understanding hexdump '-e' option

I'm trying to understand the formatting option of hexdump. I have read the man page and it says that I can tell it what format to output the data in by using the -e option. However, I can not for the life of me understand the code for the option. For now, I'm just trying to have it print random lines from /dev/random like this:

6568:6C6C:7565:7568:2E62:716D:2E2C:7563


(Basically, a psuedo IPv6 address.) However, I would really like to understand the formatting strings, not just have one that does the trick. I have tried reading the man page and it wasn't much help--it seemed to refer to it being similar to C code. Well, I have almost no experience with C, so I'm stuck. Can somebody please explain this?

-

In the manual page for hexdump, there is an entire section dedicated to the structure of the format strings (search for "A format string contains any number of format units").
hexdump -e '7 2 "%04X:" 1 2 "%04X\n"' input_file

The format string here has two parts. The first is repeated 7 times, formatting two bytes at a time formatted with "%04X:" (four hexadecimal digits with zero padding, followed by a colon). The second part is repeated once only and takes two bytes formatted with "%04X\n" to complete the line of output. This process is then repeated as more data is read from the input file.