AWK Notes

来源:互联网 发布:js当前时间加一年 编辑:程序博客网 时间:2024/04/30 06:01

#print the x field of the y line:

awk 'FNR == "'$y'" {print $"'$x'"}' file


[asicer@localhost ~]$ var=item1; printf "item1\t\t4\nitem2\t\t8\nitem3\t\t7\n" | awk -v value=$var '{
if ($1==value) 
{$2=$2+1; printf "%s\t\t%s\n", $1, $2} 
else 
{print}
}'
item1           5
item2           8
item3           7

原创粉丝点击