awk 显示指定列

root@petrusxu-ThinkPad-T430:/home/petrusxu/test# cat test.ini
id name wwn desc
1 hi 1234 fdsf
2 nj 2345 fdss
3 lo 3456 kjlh
4 mk 4567 kjiu

root@petrusxu-ThinkPad-T430:/home/petrusxu/test# cat test.ini |awk '{ for(i=1; i<=NF; i++){if($i~/wwn/) haha=i };print $haha}'
wwn
1234
2345
3456
4567

原文地址:https://www.cnblogs.com/petrusxu/p/4510960.html