linux 中awk命令指定读入分隔符

发布时间 2023-09-08 12:31:03作者: 小鲨鱼2018

 

001、 -F 指定

[root@pc1 test01]# ls
a.txt
[root@pc1 test01]# cat a.txt
a:b:c
3:8:k
f:6:3
[root@pc1 test01]# awk -F ":" '{print $1}' a.txt   
a
3
f

 

002、-v FS变量指定

[root@pc1 test01]# ls
a.txt
[root@pc1 test01]# cat a.txt
a:b:c
3:8:k
f:6:3
[root@pc1 test01]# awk -v FS=":" '{print $1}' a.txt
a
3
f