1)指定多个分隔符
参见:https://www.jianshu.com/p/e534bad0142e
使用正则:
cat .hg38_exac03_dropped | awk -F '[\t,]' '{if($5>=0.5) {print $0}}' | less -S | Wc
2)过滤模式
我们可以使用next 命令来进行过滤。
比如希望过滤文件的第一行,可以使用:
$ awk 'NR == 1 {next} {print $0}' file
其中NR 为awk 中的变量表示所在行数,使用判断;而next 命令,在awk 中,遇到则表示读入下一行,然后从头开始处理。因此,awk 前处理的内容,会默认被过滤掉。
比如下面的例子:
cat file
ab
a
b
c
d
e
f
awk '/^a/{print $0} /^a/{print $0}' file
ab
ab
a
a
awk '/^a/{print $0} {next} /^a/{print $0}' file
ab
a