[英]use awk to confront first number in every line of a file and print the whole line that contains the largest one
[英]AWK script to print line with the largest number of fields
下面的脚本显示twister.txt中的最大字段数。
awk '{if (NF > max) max = NF} END{print max}' twister.txt
我的问题是,如何显示行本身,它在twister.txt中具有最大数量的字段。
awk '{if (NF > max) {max = NF; line=$0}} END{print line}' twister.txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.