html tool

2019年1月21日星期一

xxd -seek


https://blog.csdn.net/sahusoft/article/details/6871635
https://stackoverrun.com/cn/q/11503594


# read 1 byte at offset 40C 
b_hex=$(xxd -seek $((16#40C)) -l 1 -ps A.bin -)  【popexizhi: 这里的偏移16设置40C,为什么自己测试不成功呢?】
# delete 3 least significant bits 
b_dec=$(($((16#$b_hex)) & $((2#11111000)))) 
cp A.bin B.bin 
# write 1 byte back at offset 40C 
printf "00040c: %02x" $b_dec | xxd -r - B.bin 
# 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 -p,-i,-r). Default hex.
-c cols format <cols> octets per line. Default 16 (-i: 12, -ps: 30).
-E show characters in EBCDIC. Default ASCII.
-g number of octets per group in normal output. Default 2. 每个goup的字节数,默认为2,可设置。
-h print this summary.
-i output in C include file style. :输出为c包含文件的风格,数组方式存在。
-l len stop after <len> octets. :转换到len个字节后停止转换。
-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".

没有评论:

发表评论