linux 特殊字符处理 sed awk \047 \001
程序员文章站
2022-07-10 21:14:59
...
man ascii
[root@master.vbox.com ~52]# cat -T 000000_0|grep 862298034006830|sed 's/\001/||/g'
862298034006830M6820wifi182.114.191.1470149013500000980007
862298034006830\N\N182.114.191.1470149013500000980007
[root@master.vbox.com ~53]# cat -T 000000_0|grep 862298034006830|awk -F'\001' 'BEGIN{OFS=" | "}{NF=NF;print}' |head -n 10
862298034006830 | M6820 | wifi | 182.114.191.147 | 0 | 1490 | 135 | 0 | 0 | 0 | 0 | 0 | 980007
862298034006830 | \N | \N | 182.114.191.147 | 0 | 1490 | 135 | 0 | 0 | 0 | 0 | 0 | 980007
[root@master.vbox.com ~54]# cat -T 000000_0|grep 862298034006830
862298034006830M6820wifi182.114.191.1470149013500000980007
862298034006830\N\N182.114.191.1470149013500000980007
[root@master.vbox.com ~56]# cat -v 000000_0|grep 862298034006830
862298034006830^AM6820^Awifi^A182.114.191.147^A0^A1490^A135^A0^A0^A0^A0^A0^A980007
862298034006830^A\N^A\N^A182.114.191.147^A0^A1490^A135^A0^A0^A0^A0^A0^A980007
[root@master.vbox.com ~57]#
总结了一下,sed好像不支持\001这种方式的土人白金,而awk支持,sed 有空看一下man文档再想想有没有别个办法;
也不知道vim有没有方式处理;
[root@master.vbox.com ~52]# cat -T 000000_0|grep 862298034006830|sed 's/\001/||/g'
862298034006830M6820wifi182.114.191.1470149013500000980007
862298034006830\N\N182.114.191.1470149013500000980007
[root@master.vbox.com ~53]# cat -T 000000_0|grep 862298034006830|awk -F'\001' 'BEGIN{OFS=" | "}{NF=NF;print}' |head -n 10
862298034006830 | M6820 | wifi | 182.114.191.147 | 0 | 1490 | 135 | 0 | 0 | 0 | 0 | 0 | 980007
862298034006830 | \N | \N | 182.114.191.147 | 0 | 1490 | 135 | 0 | 0 | 0 | 0 | 0 | 980007
[root@master.vbox.com ~54]# cat -T 000000_0|grep 862298034006830
862298034006830M6820wifi182.114.191.1470149013500000980007
862298034006830\N\N182.114.191.1470149013500000980007
[root@master.vbox.com ~56]# cat -v 000000_0|grep 862298034006830
862298034006830^AM6820^Awifi^A182.114.191.147^A0^A1490^A135^A0^A0^A0^A0^A0^A980007
862298034006830^A\N^A\N^A182.114.191.147^A0^A1490^A135^A0^A0^A0^A0^A0^A980007
[root@master.vbox.com ~57]#
总结了一下,sed好像不支持\001这种方式的土人白金,而awk支持,sed 有空看一下man文档再想想有没有别个办法;
也不知道vim有没有方式处理;
上一篇: ab压力测试