NR :行号
NF:列数
LM-SHC-16507744:Desktop yanwxu$ cat testd
123#ruby#3#abc
456#rechel#25#def
789#wang#30#ghi
LM-SHC-16507744:Desktop yanwxu$ awk -F# '{print NR,NF}' testd
1 4
2 4
$0:整行
LM-SHC-16507744:Desktop yanwxu$ awk -F# '{print NR,$0}' testd
1 123#ruby#3#abc
2 456#rechel#25#def
3 789#wang#30#ghi
FNR:显示多个文件的行
RS:输入行分隔符
LM-SHC-16507744:Desktop yanwxu$ cat testd
123#ruby#3#abc
456#rechel#25#def
789#wang#30#ghi
LM-SHC-16507744:Desktop yanwxu$ awk -v RS="#" '{print FNR,$0}' testd
1 123
2 ruby
3 3
4 abc
456
5 rechel
6 25
7 def
789
8 wang
9 30
10 ghi
ORS:回车换行符
LM-SHC-16507744:Desktop yanwxu$ awk -v ORS="+++" '{print NR,$0}' test
1 123 ruby 3 abc+++2 456 rechel 25 def+++3 789 wang 30 ghi+++
LM-SHC-16507744:Desktop yanwxu$ cat test
123 ruby 3 abc
456 rechel 25 def
789 wang 30 ghi
LM-SHC-16507744:Desktop yanwxu$ awk -v RS=" " -v ORS="+++" '{print NR,$0}' test
1 123+++2 ruby+++3 3+++4 abc
456+++5 rechel+++6 25+++7 def
789+++8 wang+++9 30+++10 ghi
FILENAME:显示文件名
LM-SHC-16507744:Desktop yanwxu$ awk '{print FILENAME,FNR,$0}' test testd
test 1 123 ruby 3 abc
test 2 456 rechel 25 def
test 3 789 wang 30 ghi
testd 1 123#ruby#3#abc
testd 2 456#rechel#25#def
testd 3 789#wang#30#ghi
ARGV:参数调用的数组名
awk 'BEGIN{print "aaa",ARGV[1],ARGV[2]}' test testd
aaa test testd
ARGC:数组长度
LM-SHC-16507744:Desktop yanwxu$ awk 'BEGIN{print "aaa",ARGV[1],ARGV[2],ARGC}' test testd
aaa test testd 3
这个数组包括:awk,test,testd
自定义变量
LM-SHC-16507744:Desktop yanwxu$ awk -v myVar="testVar" 'BEGIN{print myVar}'
testVar