I am looking for a command to display three .png files using xxd, displaying the first two and last two lines of the hexadecimal for each.

I have used the command below to display one file at a time but I am wondering if there is a command that can display all three files together. This is my command so far:

de@Classbox:/mnt/mountpoint/pics$ xxd albert-grumpy-cat.png |head -n2 && tail -n2

Or just perform it within xxd itself ?

$ xxd -l 32 2.png && xxd -s -32 2.png
0000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452  .PNG........IHDR
0000010: 0000 0182 0000 018b 0806 0000 00ca f595  ................
000a1b3: 8c73 a854 7b3e b0fe 3526 fd03 d868 7f6e  .s.T{>..5&...h.n
000a1c3: 763e 9a4e 0000 0000 4945 4e44 ae42 6082  v>.N....IEND.B`.

To perform on 3 files:

$ for F in 1.png 2.png 3.png; do echo $F;xxd -l 32 $F && xxd -s -32 $F;done
|improve this answer|||||
  • 2
    doh. I was completely unaware that xxd was able to seek. – mosvy Oct 31 '18 at 22:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.