[AWK] 用awk处理较为复杂的数据
一个awk(my.awk)脚本,使用方式: awk -f my.awk data.txt function strip(s){ gsub ( / ^ *| *$ / , "" , s) ; return s} function stripColon(s){a= length ( ":" )+ index (s , ":" ) ; return strip( substr (s , a))} BEGIN { OFS = "," process= 0 print "名称" , "人均消费" , "电话" , "地址" , "菜系" , "特色菜" } { if (process == 1 ){ #print myarray["name"] if ( $1 ~ "查看全部网友评论" ) { print myarray[ "name" ] , myarray[ "avg" ] , myarray[ "tel" ] , myarray[ "add" ] , myarray[ "ser" ] , myarray[ "spe...