{"id":254,"date":"2014-06-29T10:19:26","date_gmt":"2014-06-29T10:19:26","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=254"},"modified":"2014-06-29T10:19:26","modified_gmt":"2014-06-29T10:19:26","slug":"%e4%bd%bf%e7%94%a8hexdump%e6%9f%a5%e7%9c%8b%e4%ba%8c%e8%bf%9b%e5%88%b6%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/254.html","title":{"rendered":"\u4f7f\u7528hexdump\u67e5\u770b\u4e8c\u8fdb\u5236\u6587\u4ef6"},"content":{"rendered":"<div style=\"color: #000000;\">\n<p style=\"color: #333333;\">\u6709\u65f6\u5019\u9700\u8981\u67e5\u770b\u4e00\u4e9b\u4e8c\u8fdb\u5236\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u6bd4\u5982\u4e8c\u8fdb\u5236\u6587\u4ef6\u4e2d\u5305\u542b\u7684\u67d0\u4e9b\u5b57\u7b26\u4e32\u3002\u8fd9\u4e2a\u65f6\u5019\u53ef\u4ee5\u7528 hexdump \u8fdb\u884c\u67e5\u770b\u3002<\/p>\n<p style=\"color: #333333;\">\u5e38\u7528\u53c2\u6570\uff1a<\/p>\n<pre class=\"lang:default decode:true\">hexdump -C -n length -s skip file_name<\/pre>\n<p style=\"color: #333333;\">-C \u5b9a\u4e49\u4e86\u5bfc\u51fa\u7684\u683c\u5f0f\uff1b<strong><span style=\"color: #ff0000;\">-s skip \u6307\u5b9a\u4e86\u4ece\u6587\u4ef6\u5934\u8df3\u8fc7\u591a\u5c11\u5b57\u8282\uff0c\u6216\u8005\u8bf4\u662f\u504f\u79fb\u91cf\uff0c\u9ed8\u8ba4\u662f\u5341\u8fdb\u5236<\/span><\/strong>\uff0c\u5982\u679c\u662f0x\u5f00\u5934\uff0c\u5219\u662f\u5341\u516d\u8fdb\u5236\uff1b<span style=\"color: #ff0000;\">-n \u6307\u5b9a\u4e86\u5bfc\u51fa\u591a\u5c11\u957f\u5ea6\u3002<\/span><\/p>\n<\/div>\n<div style=\"color: #000000;\">\n<p style=\"color: #333333;\">\u5982\u679c\u662f\u5bfb\u627e\u6587\u672c\u5185\u5bb9\uff0c\u5219\u7ecf\u5e38\u5728\u540e\u9762\u7528\u7ba1\u9053\u8ddf\u4e0agrep\u547d\u4ee4\uff1a<\/p>\n<pre class=\"lang:default decode:true\">hexdump -C file_name | grep hellokitty<\/pre>\n<p style=\"color: #333333;\">\u8fd9\u6837\u5c31\u53ef\u4ee5\u627e\u5230\u76f8\u5173\u5185\u5bb9\u7684\u504f\u79fb\u91cf\uff0c\u7136\u540ehexdump -C -n length -s skip file_name \u67e5\u770b\u6587\u672c\u9644\u8fd1\u7684\u5185\u5bb9\u3002<\/p>\n<p style=\"color: #333333;\"><strong>\u53c2\u8003\u94fe\u63a5<\/strong>\uff1a<a href=\"http:\/\/blog.mchz.com.cn\/?p=1408\" target=\"_blank\">http:\/\/blog.mchz.com.cn\/?p=1408<\/a><\/p>\n<hr \/>\n<h5 style=\"color: #333333;\">\u7528\u9014\u8bf4\u660e<\/h5>\n<\/div>\n<p style=\"color: #000000;\">hexdump\u547d\u4ee4\u4e00\u822c\u7528\u6765\u67e5\u770b\u201c\u4e8c\u8fdb\u5236\u201d\u6587\u4ef6\u7684\u5341\u516d\u8fdb\u5236\u7f16\u7801\uff0c\u4f46\u5b9e\u9645\u4e0a\u5b83\u7684\u7528\u9014\u4e0d\u6b62\u5982\u6b64\uff0c\u624b\u518c\u9875\u4e0a\u7684\u8bf4\u6cd5\u662f\u201cascii, decimal, hexadecimal, octal dump\u201d\uff0c\u5b83\u80fd\u67e5\u770b\u4efb\u4f55\u6587\u4ef6\uff0c\u800c\u4e0d\u53ea\u9650\u4e8e\u4e8c\u8fdb\u5236\u6587\u4ef6\u3002\u53e6\u5916\u8fd8\u6709 xxd \u548c od \u4e5f\u53ef\u4ee5\u505a\u7c7b\u4f3c\u7684\u4e8b\u60c5\u3002\u5728\u7a0b\u5e8f\u8f93\u51fa\u4e8c\u8fdb\u5236\u683c\u5f0f\u7684\u6587\u4ef6\u65f6\uff0c\u5e38\u7528hexdump\u6765\u68c0\u67e5\u8f93\u51fa\u662f\u5426\u6b63\u786e\u3002\u5f53\u7136\u4e5f\u53ef\u4ee5\u4f7f\u7528Windows\u4e0a\u7684UltraEdit32\u4e4b\u7c7b\u7684\u5de5\u5177\u67e5\u770b\u6587\u4ef6\u7684\u5341\u516d\u8fdb\u5236\u7f16\u7801\uff0c\u4f46Linux\u4e0a\u6709\u73b0\u6210\u7684\u5de5\u5177\uff0c\u4f55\u4e0d\u62ff\u6765\u7528\u5462\u3002<\/p>\n<h5 style=\"color: #000000;\">\u5e38\u7528\u53c2\u6570<\/h5>\n<p style=\"color: #000000;\"><strong><span style=\"color: #ff0000;\">\u5982\u679c\u8981\u770b\u5230\u8f83\u7406\u60f3\u7684\u7ed3\u679c\uff0c\u63a8\u8350\u4f7f\u7528-C\u53c2\u6570\uff0c\u663e\u793a\u7ed3\u679c\u5206\u4e3a\u4e09\u5217\uff08\u6587\u4ef6\u504f\u79fb\u91cf\u3001\u5b57\u8282\u7684\u5341\u516d\u8fdb\u5236\u3001ASCII\u5b57\u7b26\uff09\u3002<\/span><\/strong><\/p>\n<p style=\"color: #000000;\">\u683c\u5f0f\uff1ahexdump -C binfile<\/p>\n<p style=\"color: #000000;\">\u4e00\u822c\u6587\u4ef6\u90fd\u4e0d\u662f\u592a\u5c0f\uff0c\u6700\u597d\u7528less\u6765\u914d\u5408\u4e00\u4e0b\u3002<\/p>\n<p style=\"color: #000000;\">\u683c\u5f0f\uff1ahexdump -C binfile | less<\/p>\n<h6 style=\"color: #000000;\">\u793a\u4f8b\u4e00 \u6bd4\u8f83\u5404\u79cd\u53c2\u6570\u7684\u8f93\u51fa\u7ed3\u679c<\/h6>\n<pre class=\"lang:default decode:true\">[root@new55 ~]# echo \/etc\/passwd | hexdump\n0000000 652f 6374 702f 7361 7773 0a64\n000000c\n[root@new55 ~]# echo \/etc\/passwd | od -x\n0000000 652f 6374 702f 7361 7773 0a64\n0000014\n[root@new55 ~]# echo \/etc\/passwd | xxd\n0000000: 2f65 7463 2f70 6173 7377 640a            \/etc\/passwd.\n[root@new55 ~]# echo \/etc\/passwd | hexdump -C      &lt;== \u89c4\u8303\u7684\u5341\u516d\u8fdb\u5236\u548cASCII\u7801\u663e\u793a\uff08Canonical hex+ASCII display \uff09\n00000000  2f 65 74 63 2f 70 61 73  73 77 64 0a              |\/etc\/passwd.|\n0000000c\n[root@new55 ~]# echo \/etc\/passwd | hexdump -b      &lt;== \u5355\u5b57\u8282\u516b\u8fdb\u5236\u663e\u793a\uff08One-byte octal display\uff09\n0000000 057 145 164 143 057 160 141 163 163 167 144 012\n000000c\n[root@new55 ~]# echo \/etc\/passwd | hexdump -c      &lt;== \u5355\u5b57\u8282\u5b57\u7b26\u663e\u793a\uff08One-byte character display\uff09\n0000000   \/   e   t   c   \/   p   a   s   s   w   d  \\n\n000000c\n[root@new55 ~]# echo \/etc\/passwd | hexdump -d      &lt;== \u53cc\u5b57\u8282\u5341\u8fdb\u5236\u663e\u793a\uff08Two-byte decimal display\uff09\n0000000   25903   25460   28719   29537   30579   02660\n000000c\n[root@new55 ~]# echo \/etc\/passwd | hexdump -o       &lt;== \u53cc\u5b57\u8282\u516b\u8fdb\u5236\u663e\u793a\uff08Two-byte octal display\uff09\n0000000  062457  061564  070057  071541  073563  005144\n000000c\n[root@new55 ~]# echo \/etc\/passwd | hexdump -x       &lt;== \u53cc\u5b57\u8282\u5341\u516d\u8fdb\u5236\u663e\u793a\uff08Two-byte hexadecimal display\uff09\n0000000    652f    6374    702f    7361    7773    0a64\n000000c\n[root@new55 ~]# echo \/etc\/passwd | hexdump -v\n0000000 652f 6374 702f 7361 7773 0a64\n000000c<\/pre>\n<p style=\"color: #000000;\"><span style=\"color: #ff0000;\">\u6bd4\u8f83\u6765\u6bd4\u8f83\u53bb\uff0c\u8fd8\u662fhexdump -C\u9009\u9879\u7684\u663e\u793a\u6548\u679c\u66f4\u597d\u4e9b\u3002<\/span><\/p>\n<h6 style=\"color: #000000;\">\u793a\u4f8b\u4e8c \u786e\u8ba4\u6587\u672c\u6587\u4ef6\u7684\u683c\u5f0f<\/h6>\n<p style=\"color: #000000;\"><span style=\"color: #ff0000;\">\u6587\u672c\u6587\u4ef6\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u7684\u884c\u7ed3\u675f\u6807\u5fd7\u662f\u4e0d\u4e00\u6837\u7684\uff0c\u7ecf\u5e38\u4f1a\u78b0\u5230\u7531\u6b64\u5e26\u6765\u7684\u95ee\u9898\u3002\u6bd4\u5982Linux\u7684\u8bb8\u591a\u547d\u4ee4\u4e0d\u80fd\u5f88\u597d\u7684\u5904\u7406DOS\u683c\u5f0f\u7684\u6587\u672c\u6587\u4ef6\u3002Windows\/DOS\u4e0b\u7684\u6587\u672c\u6587\u4ef6\u662f\u4ee5&#8221;\\r\\n&#8221;\u4f5c\u4e3a\u884c\u7ed3\u675f\u7684\uff0c\u800cUnix\/Linux\u4e0b\u7684\u6587\u672c\u6587\u4ef6\u662f\u4ee5&#8221;\\n&#8221;\u4f5c\u4e3a\u884c\u7ed3\u675f\u7684\u3002<\/span><\/p>\n<pre class=\"lang:default decode:true \">[root@new55 ~]# cat test.bc\n123*321\n123\/321\nscale=4;123\/321\n\n[root@new55 ~]# hexdump -C test.bc\n00000000  31 32 33 2a 33 32 31 0a   31 32 33 2f 33 32 31 0a  |123*321.123\/321.|\n00000010  73 63 61 6c 65 3d 34 3b  31 32 33 2f 33 32 31 0a  |scale=4;123\/321.|\n00000020  0a                                                |.|\n00000021\n[root@new55 ~]#\n\n\u6ce8\uff1a\u5e38\u89c1\u7684ASCII\u5b57\u7b26\u7684\u5341\u516d\u8fdb\u5236\u8868\u793a\n\\r  0D\n\\n  0A\n\\t  09\n\nDOS\/Windows\u7684\u6362\u884c\u7b26 \\r\\n    \u5373\u5341\u516d\u8fdb\u5236\u8868\u793a 0D 0A\nLinux\/Unix\u7684\u6362\u884c\u7b26  \\n      \u5373\u5341\u516d\u8fdb\u5236\u8868\u793a 0A<\/pre>\n<p><strong>\u53c2\u8003\u94fe\u63a5<\/strong>\uff1a<a href=\"http:\/\/codingstandards.iteye.com\/blog\/805778\" target=\"_blank\">http:\/\/codingstandards.iteye.com\/blog\/805778<\/a><\/p>\n<hr \/>\n<h6>hexdump \/ xxd \/ od<\/h6>\n<p>\u7cfb\u7edf\u81ea\u5e26\u90fd\u6709\uff0c\u6240\u4ee5\u5728Linux\u4e0b\u505a\u8fdb\u5236\u8f6c\u6362\u771f\u7684\u662f\u592a\u65b9\u4fbf\u4e86\u3002<\/p>\n<p>\u6ce8\uff1a\u4e09\u4e2a\u547d\u4ee4\u90fd\u53ef\u4ee5\u50cfUltraEdit\u90a3\u6837\u4ee516\u8fdb\u5236\u7684\u65b9\u5f0f\u67e5\u770b\u6587\u4ef6\u3002hexdump\u7684\u8f93\u51fa\u683c\u5f0f\u6700\u7075\u6d3b\uff0c\u56e0\u4e3a\u5b83\u6709\u4e13\u95e8\u7684\u53c2\u6570\u6307\u5b9a\u683c\u5f0f\uff1b\u4e0d\u77e5\u9053od\u7684\u7279\u70b9\u5728\u54ea\uff0cod -x \u548c\u4e0d\u5e26\u9009\u9879\u7684xxd\u5dee\u4e0d\u591a\uff1bxxd\u8fd8\u53ef\u4ee5\u901a\u8fc7-r\u9009\u9879\u628a16\u8fdb\u5236\u8868\u793a\u7684\u53cd\u8f6c\u6362\u4e3a\u6b63\u5e38\u7684\u6587\u4ef6\uff0c\u4e2a\u4eba\u611f\u89c9xxd\u6700\u201c\u6b63\u5e38\u201d\uff0c\u56e0\u4e3a\u5b83\u9ed8\u8ba4\u7684\u8868\u793a\u65b9\u5f0f\u548cUltraEdit\u6700\u50cf\uff1a\u4ee5\u4f4d\u79fb\u5f00\u5934\uff0c\u7136\u540e\u6bcf\u4e24\u5b57\u8282\u4e00\u7ec4\uff0c\u6bcf\u884c\u6700\u540e\u6709\u76f8\u5e94\u5b57\u8282\u7684\u6587\u4ef6\u663e\u793a\u3002<\/p>\n<p><a href=\"http:\/\/hi.baidu.com\/gsxwgtvhgabbjrq\/item\/3d4d771ad1c66d8b88a95681\" target=\"_blank\">http:\/\/hi.baidu.com\/gsxwgtvhgabbjrq\/item\/3d4d771ad1c66d8b88a95681<\/a><\/p>\n<hr \/>\n<h5>hexdump\u7684\u9ad8\u7ea7\u7528\u6cd5<\/h5>\n<p>-e\u00a0\u00a0<strong><span style=\"color: #ff0000;\">\u6307\u5b9a\u683c\u5f0f\u5b57\u7b26\u4e32<\/span><\/strong>\uff0c\u683c\u5f0f\u5b57\u7b26\u4e32\u5305\u542b\u5728\u4e00\u5bf9\u5355\u5f15\u53f7\u4e2d\uff0c\u683c\u5f0f\u5b57\u7b26\u4e32\u5f62\u5982\uff1a<\/p>\n<pre class=\"lang:default decode:true\">'a\/b \"format1\" \"format2\"'<\/pre>\n<p>\u6bcf\u4e2a\u683c\u5f0f\u5b57\u7b26\u4e32\u7531\u4e09\u90e8\u5206\u7ec4\u6210\uff0c\u6bcf\u4e2a\u7531\u7a7a\u683c\u5206\u9694\uff0c\u7b2c\u4e00\u4e2a\u5f62\u5982a\/b\uff0cb\u8868\u793a\u5bf9\u6bcfb\u4e2a\u8f93\u5165\u5b57\u8282\u5e94\u7528format1\u683c\u5f0f\uff0ca\u8868\u793a\u6bcfa\u4e2a\u5b57\u8282\u4e00\u7ec4\u4e00\u8d77\u663e\u793a\uff0c\u53e6\u5916a\u53ef\u4ee5\u7701\u7565\uff0c\u7701\u7565\u5219a=1\u3002format1\u548cformat2\u4e2d\u53ef\u4ee5\u4f7f\u7528\u7c7b\u4f3cprintf\u7684\u683c\u5f0f\u5b57\u7b26\u4e32\uff0c\u5982\uff1a<\/p>\n<ul>\n<li>%02d\uff1a\u4e24\u4f4d\u5341\u8fdb\u5236<\/li>\n<li>%03x\uff1a\u4e09\u4f4d\u5341\u516d\u8fdb\u5236<\/li>\n<li>%02o\uff1a\u4e24\u4f4d\u516b\u8fdb\u5236<\/li>\n<li>%c\uff1a\u5355\u4e2a\u5b57\u7b26\u7b49<\/li>\n<\/ul>\n<p>\u8fd8\u6709\u4e00\u4e9b\u7279\u6b8a\u7684\u7528\u6cd5\uff1a<\/p>\n<ul>\n<li>%_ad\uff1a\u6807\u8bb0\u4e0b\u4e00\u4e2a\u8f93\u51fa\u5b57\u8282\u7684\u5e8f\u53f7\uff0c\u7528\u5341\u8fdb\u5236\u8868\u793a<\/li>\n<li>%_ax\uff1a\u6807\u8bb0\u4e0b\u4e00\u4e2a\u8f93\u51fa\u5b57\u8282\u7684\u5e8f\u53f7\uff0c\u7528\u5341\u516d\u8fdb\u5236\u8868\u793a<\/li>\n<li>%_ao\uff1a\u6807\u8bb0\u4e0b\u4e00\u4e2a\u8f93\u51fa\u5b57\u8282\u7684\u5e8f\u53f7\uff0c\u7528\u516b\u8fdb\u5236\u8868\u793a<\/li>\n<li>%_p\uff1a\u5bf9\u4e0d\u80fd\u4ee5\u5e38\u89c4\u5b57\u7b26\u663e\u793a\u7684\u7528.\u4ee3\u66ff<\/li>\n<\/ul>\n<p>\u540c\u4e00\u884c\u5982\u679c\u8981\u663e\u793a\u591a\u4e2a\u683c\u5f0f\u5b57\u7b26\u4e32\uff0c\u5219\u53ef\u4ee5\u8ddf\u591a\u4e2a-e\u9009\u9879<\/p>\n<h6>\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<p><a href=\"http:\/\/www.cnblogs.com\/openix\/archive\/2012\/03\/19\/2406568.html\" target=\"_blank\">http:\/\/www.cnblogs.com\/openix\/archive\/2012\/03\/19\/2406568.html<\/a><\/p>\n<p><span style=\"color: #0000ff;\"><strong>\u663e\u793a\u6bcf\u4e2a\u5b57\u7b26\u5bf9\u5e94\u7684\u5341\u8fdb\u5236\u3001\u5341\u516d\u8fdb\u5236\u3001\u516b\u8fdb\u5236\u7684Bash\u811a\u672c<\/strong><\/span><\/p>\n<pre class=\"lang:default decode:true \">#!\/bin\/bash\nASCII=\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\necho $ASCII | hexdump -v -e '\"%02_ad \"' -e '1\/1 \"%1c \"' -e '1\/1 \"hex=%02X \"' -e '1\/1 \"dec=%3d \"' -e '1\/1 \"oct=%03o\\n\"'<\/pre>\n<p>=EOF=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u65f6\u5019\u9700\u8981\u67e5\u770b\u4e00\u4e9b\u4e8c\u8fdb\u5236\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u6bd4\u5982\u4e8c\u8fdb\u5236\u6587\u4ef6\u4e2d\u5305\u542b\u7684\u67d0\u4e9b\u5b57\u7b26\u4e32\u3002\u8fd9\u4e2a\u65f6\u5019\u53ef\u4ee5\u7528 hexdump \u8fdb\u884c\u67e5\u770b [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,6,12],"tags":[122],"class_list":["post-254","post","type-post","status-publish","format-standard","hentry","category-linux","category-other","category-tools","tag-hexdump"],"views":3942,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/254","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=254"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/254\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=254"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}