linux命令:xxd读取二进制文件

帮助文档

l@l-PC:/lib64$ xxd --help                                                                                                                                                             
Usage:                                                                                                                                                                                        
       xxd [options] [infile [outfile]]                                                                                                                                                       
    or                                                                                                                                                                                        
       xxd -r [-s [-]offset] [-c cols] [-ps] [infile [outfile]]                                                                                                                               
Options:                                                                                                                                                                                      
    -a          toggle autoskip: A single '*' replaces nul-lines. Default off.                                                                                                                
    -b          binary digit dump (incompatible with -ps,-i,-r). Default hex.                                                                                                                 
    -C          capitalize variable names in C include file style (-i).                                                                                                                       
    -c cols     format <cols> octets per line. Default 16 (-i: 12, -ps: 30).                                                                                                                  
    -E          show characters in EBCDIC. Default ASCII.                                                                                                                                     
    -e          little-endian dump (incompatible with -ps,-i,-r).                                                                                                                             
    -g          number of octets per group in normal output. Default 2 (-e: 4).                                                                                                               
    -h          print this summary.
    -i          output in C include file style.
    -l len      stop after <len> octets.
    -o off      add <off> to the displayed file position.
    -ps         output in postscript plain hexdump style.
    -r          reverse operation: convert (or patch) hexdump into binary.
    -r -s off   revert with <off> added to file positions found in hexdump.
    -s [+][-]seek  start at <seek> bytes abs. (or +: rel.) infile offset.
    -u          use upper case hex letters.
    -v          show version: "xxd V1.10 27oct98 by Juergen Weigert".

用法

直接读取xxd

l@l-PC:~$ cat 1.txt 
12345
l@l-PC:~$ xxd 1.txt 
00000000: 3132 3334 350a                           12345.

指定格式[-ps]

output in postscript plain hexdump style

l@l-PC:~$ xxd -ps  1.txt 
31323334350a

指定长度[-l 3]

l@l-PC:~$ xxd -ps -l 3  1.txt 
313233

指定偏移[-s1]

l@l-PC:~$ xxd -ps -l 3  -s1 1.txt 
323334

转换[-r]

l@l-PC:~$ xxd -ps  1.txt  > 1.bin
l@l-PC:~$ 
l@l:~$ xxd  -r -ps  1.bin
12345
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值