awk 判断格式
awk '{print ($1>$2)?"第一排"$1:"第二排"$2}' # 条件判断 括号代表if语句判断 "?"代表then ":"代表else
awk '{max=($1>$2)? $1 : $2; print max}' # 条件判断 如果$1大于$2,max值为为$1,否则为$2
awk '{if ( $6 > 50) print $1 " Too high" ;\
else print "Range is OK"}' file
awk '{if ( $6 > 50) { count++;print $3 } \
else { x+5; print $2 } }' file
awk 循环格式
awk '{i = 1; while ( i <= NF ) { print NF, $i ; i++ } }' file
awk '{ for ( i = 1; i <= NF; i++ ) print NF,$i }' file