1
ifaii 2018-11-17 19:07:02 +08:00
x='|STRTOBEINSERT|'
perl -pe "s/(.*?)(,)(.*?)(,)(.*$)/\1\2\3$x\4\5/g || s/(.*?)(,)(.*$)/\1$x\2\3/g" filename 我又复习了一次 perl 的用法 |
2
ifaii 2018-11-17 19:09:32 +08:00 1
看错题目了,稍微改一下参数位置即可
x='|STRTOBEINSERT|' perl -pe "s/(.*?)(,)(.*?)(,)(.*$)/\1\2\3$x\4\5/g || s/(.*?)(,)(.*$)/\1\2\3$x/g" filename |
3
l76862157 2018-11-17 19:29:31 +08:00 1
awk -F',' '{if(NF==2){print $0", STRTOBEINSERT"} else if(NF==3){print $1","$2", STRTOBEINSERT,"$3}else{print}}'
|
4
DiamondbacK 2018-11-17 19:31:02 +08:00 1
sed 's/[^,]*,[^,]*/&,STRTOBEINSERT/'
gawk 'NF>1 {$2=$2 ",STRTOBEINSERT"} {print}' FS=, OFS=, |
5
uuspider 2018-11-17 19:31:26 +08:00 2
sed 's/\([^,]*,[^,]*\)\(.*\)/\1,STRTOBEINSERT\2/'
|
6
maxduke OP 以上各位回复都感谢啦,🙏
|