Linux awk: print中存在变量的情况

对于awk '{print $icol}' temp.txt打印文件中第icol(icol为变量)列的情况,可通过下述方法实现:

icol = 8
awk  -v  t="${icol}"  '{print $t}'  temp.txt

转载于:https://blog.51cto.com/linux10000/2411213

猜你喜欢

转载自blog.csdn.net/weixin_34121304/article/details/92879195
今日推荐