https://www.cnblogs.com/itxiongwei/p/5546000.html
{cmd1; cmd2; cmd3}
cat test.txt | awk -F'|' '{if( $1 == 0) {sub("^ *", "", $2); sub(" *$", "", $2); print $2}}'
命令识别的时候,自动会忽略其中多余的空格。
.
cat test.txt | awk -F'|' '{if($1 == 0) {cmd="echo "$2; system(cmd)}}'
https://blog.csdn.net/cy_cai/article/details/41908921
cat test.txt | awk -F'|' '{if($1 == 0) {cmd="echo $2"; system(cmd)}}'
cat test.txt | awk -F'|' '{if($1 == 0) cmd="echo "$2; system(cmd)}'
cat test.txt | awk -F'|' '{if($2 != "") {cmd="echo $2"; system(cmd)}}'
local varValue=`echo "$DB_INFO" | awk -F\| '{print $1 $2 $3 $4}' | awk -v "FRAME=$FRAME" -v "SLOT=$SLOT" -v "varName=$varName" '{if ($1 == FRAME && $2 == SLOT && $3 == varName ) print $4}' | tr -d ' '`
定义变量的话, 在action中替换, 直接使用变量名就好, 不需要使用$符号。
cat test.txt | awk -F'|' -v "test_str=$test_str" '{if($1 == 0) {cmd="echo "test_str; system(cmd)}}'
数组使用
awk中使用数组。
https://blog.csdn.net/ithomer/article/details/8478716
http://www.zsythink.net/archives/2093
http://www.361way.com/awk-get-external-variable/4930.html