2014-11-01 11 views
7

如何將hexdump中打印的列數從默認的16(更改爲21)?如何更改`hexdump`中打印的列數?

或者在哪裏可以找到要更改的地方默認格式字符串用於hexdump爲了修改那裏使用的數字?

+6

你可以試試這個'hexdump -e '21/1「%02x」「\ n」'' – 2014-11-01 22:53:36

+0

@gniourf_gniourf它的工作原理!謝謝。 – 2014-11-01 23:09:10

+0

請查找也包含有關默認格式信息的答案。 – 2014-11-01 23:18:34

回答

6

看來,默認格式是這樣得到的:

hexdump -e '"%07.7_Ax\n"' -e '"%07.7_ax " 8/2 "%04x " "\n"' 

man hexdump

Implement the -x option: 

     "%07.7_Ax\n" 
     "%07.7_ax " 8/2 "%04x " "\n" 

如果您想了解hexdump的格式,你必須閱讀說明書,但是這裏有一個簡短的步驟:

  • 第一部分%07.7_Ax\n是顯示僅包含偏移量的最後一行的部分。每本手冊:

    _a[dox]  Display the input offset, cumulative across input files, of the 
          next byte to be displayed. The appended characters d, o, and x 
          specify the display base as decimal, octal or hexadecimal 
          respectively. 
    
    _A[dox]  Identical to the _a conversion string except that it is only 
          performed once, when all of the input data has been processed. 
    
  • 對於第二:我們現在明白了"%07.7_ax "部分。 8/2表示8次迭代,以下爲2個字節,"%04x "。最後,在這些之後,我們有一個換行符:"\n"

我真的不知道你怎麼想你的21個字節,這也許會做:

hexdump -e '"%07.7_Ax\n"' -e '"%07.7_ax " 21/1 "%02x " "\n"' 

,你知道如何擺脫的偏移量,如果需要的話:

hexdump -e '21/1 "%02x " "\n"'