語法 awk [ -F re] [parameter...] ['pattern {action}' ] [-f progfile][in_file...] 獲得普通外部變數 [xingxing.dxx@30_28_6_20 ~]$ test='test code' [xingxing.dxx@30
語法
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 code
-
BEGIN快中獲取變數
-
[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=1 SHLVL=1