Search code examples
hexdump

How to hexdump large files


I would like to output a hexdump result of a 8go file. Is it possible to do it piece by piece ? How to specify a limited numbers of lines (I have read the man page and it seems to correpond to -n length, but it didn't work)


Solution

  • Something like this? Dump i.e. byte 3600 to 3700:

    $ hexdump -n 100 -s 3600 -v -e '32/1 "%02x" "\n"' some_file
    
    -s 3600 ; search to offset 3600 before starting dump.
    -n 100 ; dump 100 bytes.
    -e '32/1 "%02x" "\n"' ; dump 32 bytes pr. line and print by 1 as zero padded hex.
    

    If you need line offset instead of byte you might have to resort to e.g. sed:

    $ sed -n '3701q;3600,3700p' some_file | hexdump -ve '32/1 "%02x" "\n"'
    

    Depending all on what you are going to use the data for it is also a good candidate for a short C program ;P