$ cat marks.txt
1) Amit Physics 80
2) Rahul Maths 90
3) Shyam Biology 87
4) Kedar English 85
5) Hari History 89
如下: 我把分隔符换成了"--",
$ cat marks.txt |awk --profile 'FS="--"{print "****" $1,$2}'
**1) Amit
**2) Rahul Maths 90
**3) Shyam Biology 87
**4) Kedar English 85
**5) Hari History 89
对输出结果感到不理解, 没有找到分隔符,awk内部是如何实现的?
没找到分隔符,视为只有1列,$2就是空
另外,FS要放到BEGIN里:
awk --profile 'BEGIN{FS="--"}{print "**" $1,$2}'