
1、调用awk
awk [options] -f progfile [--] file ...
awk [options] [--] 'program' file ...
2、命令行选项
-F fs
--field-separator fs
设置字段分隔符,如打印用户:
awk -F : '{print $1}' /etc/passwd
-f source-file
--file source-file
从文件读取程序,如:awk -f file /etc/passwd
file内容为:
#!/bin/awk -f
BEGIN {FS=":"}
{print $1}
-v var=val
--assign var=val
设置var的值为val,如:awk -v foo=hello -v bar=world 'BEGIN {print foo,bar}'
3、包含其它文件到awk程序
@include "test1"
BEGIN {
print "This is script test2."
}
