1.awk的三种形式
awk '{comman}' inputfile
awk -F "sparator" '{command}' inputfile
awk -f awkfile inputfile
2.awk的默认分隔符是空格。
3.在awk中可以打印报告头和报告尾,其格式为
awk -F ";" 'BEGIN{print "HELO world"} {print $1} END{print "BYE world"} ' inputfile
4.awk中if语句及正则表达式的几种应用形式
awk '/[Gg]reen/' grade.txt
awk '$1 ~ /[Gg]reen/' grade.txt (找出$1匹配正则表达式的行)
awk '{if($1>=100) print "Helo"}' grade.txt
awk '$1~/(Yellow|Brown)/' grade.txt (配置Yellow或Brown的行)