1. 实现 以= [ 或其他符号实现对齐
chown = CHange OWNer
chsh = CHange SHell
cmp = compare
cobra = Common Object Request Broker Architecture
comm = common
cp = CoPy
cpio = CoPy In and O
2. 补齐-------使得总长相同,以总长最长为标准
#sdasdadsdad----------------------------
#作为-------------------
#作为表的数组-----------------------
shell_master 于 2011-11-26 17:06:06发表:
没有解决?
irwin520 于 2011-11-17 09:35:39发表:
我测试了 好像没有对齐,结果如下:
[irwin@IRWIN test]$ cat net1|awk -v RS= -F "\n" '{for(i=1;$i != "";i++){split($i,x,"=");if(length(x[1])>max){max=length(x[1])}};m=max"";for(i=1;$i != "";i++){split($i,x,"=");printf "\"%" m "s=%s\"",x[1],x[2];printf "\n"}}'|sed 's/"//g'
chown = CHange OWNer
chsh = CHange SHell
cmp = compare
cobra = Common Object Request Broker Architecture
comm = common
cp = CoPy
cpio = CoPy In and O
文件如下:
[irwin@IRWIN test]$ cat net1
chown = CHange OWNer
chsh = CHange SHell
cmp = compare
cobra = Common Object Request Broker Architecture
comm = common
cp = CoPy
cpio = CoPy In and O
[irwin@IRWIN test]$
irwin520 于 2011-11-17 09:29:54发表:
2# ICEEN
这个好像也不能实现吧。
tim211314 于 2011-10-28 20:32:39发表:
第一个
cat filename|awk -v RS= -F "\n" '{for(i=1;$i != "";i++){split($i,x,"=");if(length(x[1])>max){max=length(x[1])}};m=max"";for(i=1;$i != "";i++){split($i,x,"=");printf "\"%" m "s=%s\"",x[1],x[2];printf "\n"}}'|sed 's/"//g'
书中、颜如玉 于 2011-09-27 15:36:36发表:
awk? 截取?
ICEEN 于 2011-09-05 22:37:23发表:
前一个已解决 sed 's/[[:space:]]=/\t=/g'