日期:2014-05-16 浏览次数:20645 次
fe:48->fe48
00:00->0
03:00->300
0002->2
00:10->10
00:09->9
c9:03->c903
b2:58->b258
A="fe:48:00:00:03:00:00:02:00:10:00:09:c9:03:b2:58"
B=`echo $A
------解决方案--------------------
sed 's/\(..\):\(..\)/\1\2/g;s/\<0*\([0-9]\)/\1/g'`
echo $B
[nicenight@CSDN ~]$ B=$(echo -n $A
------解决方案--------------------
awk -v RS=":" -v ORS=":" '{getline nextline; $0=$0""nextline; sub(/^0*/, "", $0); $0=$0==""?0:$0; result=result=="" ? $0 : result ORS $0} END{printf result}')
[nicenight@CSDN ~]$ echo $B
fe48:0:300:2:10:9:c903:b258