语法
awk [ -F re] [parameter...] ['pattern {action}' ] [-f progfile][in_file...]
- 获得普通外部变量
[xingxing.dxx@30_28_6_20 ~]$ test='test code'
[xingxing.dxx@30_28_6_20 ~]$ echo | awk '{print test}' test="$test"
test codeBEGIN快中获取变量
[xingxing.dxx@30_28_6_20 ~]$ test='test code'
[xingxing.dxx@30_28_6_20 ~]$ echo | awk -v test="$test" 'BEGIN{print test}'
test code[xingxing.dxx@30_28_6_20 ~]$ echo | awk -v test="$test" '{print test}'
test code- 获取环境变量
[xingxing.dxx@30_28_6_20 ~]$ awk 'BEGIN{for (i in ENVIRON) {print i"="ENVIRON[i];}}'
TERM=linux
G_BROKEN_FILENAMES=
SHLVL=