日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

Linux命令学习总结:hexdump

發布時間:2023/11/27 生活经验 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux命令学习总结:hexdump 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

命令簡介:

hexdump是Linux下的一個二進制文件查看工具,它可以將二進制文件轉換為ASCII、八進制、十進制、十六進制格式進行查看。

指令所在路徑:/usr/bin/hexdump

?

命令語法:

hexdump: [-bcCdovx] [-e fmt] [-f fmt_file] [-n length] [-s skip] [file ...]

?

命令參數:

此命令參數是Red Hat Enterprise Linux Server release 5.7下hexdump命令參數,不同版本Linux的hexdump命令參數有可能不同。

參數

長參數

描敘

-b

?

每個字節顯示為8進制。一行共16個字節,一行開始以十六進制顯示偏移值

-c

?

每個字節顯示為ASCII字符

-C

?

每個字節顯示為16進制和相應的ASCII字符

-d

?

兩個字節顯示為10進制

-e

?

格式化輸出

-f

?

Specify a file that contains one or more newline separated format strings.? Empty lines and lines whose first non-blank character is a hash mark (#) are ignored.

-n

?

只格式前n個長度的字符

-o

?

兩個字節顯示為8進制

-s

?

從偏移量開始輸出

-v

?

The -v option causes hexdump to display all input data.? Without the -v option, any number of groups of output lines, which would be identical to the immediately preceding group of output lines

-x

?

雙字節十六進制顯示

?

使用示例:

?

1: 查看hexdmp命令的幫助信息

[root@DB-Server ~]# man hexdump

?

2: 以8進制顯示文件里面的字符。

[root@DB-Server ~]# cat >test.txt
ABCDEF??? 
GHIJKM
123456
[root@DB-Server ~]#? hexdump -b test.txt
0000000 101 102 103 104 105 106 012 107 110 111 112 113 115 012 061 062
0000010 063 064 065 066 012??????????????????????????????????????????? 
0000015

注意:一行共16個字節,一行開始以十六進制顯示偏移值(如下所示,第一行字符串只顯示到D,第十六個字節,后面的F12*DFDF換行顯示)

[root@DB-Server ~]# cat >test.txt
ABCDEFGHIJKLMNODF12*DFDF
?
[2]+? Stopped???????????????? cat > test.txt
You have new mail in /var/spool/mail/root
[root@DB-Server ~]# hexdump -b test.txt 
0000000 101 102 103 104 105 106 107 110 111 112 113 114 115 116 117 104
0000010 106 061 062 052 104 106 104 106 012??????????????????????????? 
0000019
[root@DB-Server ~]# hexdump -c test.txt 
0000000?? A?? B?? C?? D?? E?? F?? G?? H?? I?? J?? K?? L?? M?? N?? O?? D
0000010?? F?? 1?? 2?? *?? D?? F?? D?? F? \n??????????????????????????? 
0000019

?

3:以ASCII字符顯示文件中字符

[root@DB-Server ~]# hexdump -c test.txt 
0000000?? A?? B?? C?? D?? E?? F?? G?? H?? I?? J?? K?? L?? M?? N?? O?? D
0000010?? F?? 1?? 2?? *?? D?? F?? D?? F? \n??????????????????????????? 
0000019
?

hexdump 以ASCII字符顯示時,可以輸出換行符,這個功能可以用來檢查文件是Linux的換行符格式還是Widows格式換行符。如下所示

?

4:以16進制和相應的ASCII字符顯示文件里的字符

[root@DB-Server ~]# hexdump -C test.txt 
00000000? 41 42 43 44 45 46 47 48? 49 4a 4b 4c 4d 4e 4f 44? |ABCDEFGHIJKLMNOD|
00000010? 46 31 32 2a 44 46 44 46? 0a?????????????????????? |F12*DFDF.|
00000019

?

5:只格式文件中前n個字符

[root@DB-Server ~]# hexdump -C -n 5 test.txt 
00000000? 41 42 43 44 45??????????????????????????????????? |ABCDE|
00000005

?

6:以偏移量開始格式輸出。如下所示指定參數-s 5 ,前面的ABCDE字符沒有了。

?
[root@DB-Server ~]# hexdump -C test.txt 
00000000? 41 42 43 44 45 46 47 48? 49 4a 4b 4c 4d 4e 4f 44? |ABCDEFGHIJKLMNOD|
00000010? 46 31 32 2a 44 46 44 46? 0a?????????????????????? |F12*DFDF.|
00000019
[root@DB-Server ~]# hexdump -C -s 5 test.txt 
00000005? 46 47 48 49 4a 4b 4c 4d? 4e 4f 44 46 31 32 2a 44? |FGHIJKLMNODF12*D|
00000015? 46 44 46 0a?????????????????????????????????????? |FDF.|
00000019

轉載于:https://www.cnblogs.com/kerrycode/p/5077687.html

總結

以上是生活随笔為你收集整理的Linux命令学习总结:hexdump的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。