标签:des style blog color 使用 io 文件 数据
1 #!/bin/bash - 2 #=============================================================================== 3 # 4 # FILE: hex_change.sh 5 # 6 # USAGE: ./hex_change.sh 7 # 8 # DESCRIPTION: 9 # 10 # OPTIONS: --- 11 # REQUIREMENTS: --- 12 # BUGS: --- 13 # NOTES: --- 14 # AUTHOR: linkscue (scue), linkscue@gmail.com 15 # ORGANIZATION: 16 # CREATED: 2014年08月07日 00时05分55秒 CST 17 # REVISION: --- 18 #=============================================================================== 19 20 # hex_change 修改二进制文件 21 # 语法:hex_change 00ABCDEF 00ABCDEF file 22 # hex_change [0x]00ABCDEF [0x]00ABCDEF file 23 hex_change(){ 24 local hex=${1#0x} 25 local hexnew=${2#0x} 26 local bin=$3 27 hex=$(echo $hex|tr a-z A-Z) # 小写转大写 28 hexnew=$(echo $hexnew|tr a-z A-Z) # 小写转大写 29 echo "convert hex: 0x$hex 0x$hexnew" 30 p1="\x${hex:6:2}" 31 p2="\x${hex:4:2}" 32 p3="\x${hex:2:2}" 33 p4="\x${hex:0:2}" 34 pn1="\x${hexnew:6:2}" 35 pn2="\x${hexnew:4:2}" 36 pn3="\x${hexnew:2:2}" 37 pn4="\x${hexnew:0:2}" 38 echo sed -i "s/$p1$p2$p3$p4/$pn1$pn2$pn3$pn4/g" $bin 39 sed -i "s/$p1$p2$p3$p4/$pn1$pn2$pn3$pn4/g" $bin 40 } 41 42 hex_change ABCDEF55 DDCCBBAA ./1.bin
〖Linux〗使用sed命令修改小端(little endian)存储的数据,布布扣,bubuko.com
〖Linux〗使用sed命令修改小端(little endian)存储的数据
标签:des style blog color 使用 io 文件 数据
原文地址:http://www.cnblogs.com/scue/p/3896112.html