Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编写一个 AWK 脚本,它采用日期列表并将其格式化为更易于阅读的列表。我能够做到这一点没问题。
真正的问题是这个。显示列表后,我想显示“2010”在文本文件中出现的次数。
我该怎么做呢?我已经搜索了好几天,但我一无所获。
awk -F"2010" 'NF>0 { count += NF-1 } END { print 0+count }
awk '{ for (i=1;i<=NF;i++) if ( $i == "2010" ) count++ } END { print count }' myfile.txt