This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
The community reviewed whether to reopen this question 2 years ago and left it closed:
Original close reason(s) were not resolved
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
下次请展示您的文件示例以及您想用它做什么(显示所需的输出)。猜猜你想要什么,
记录总数用NR表示。
当前的记录总数用FNR表示。
Please show a sample of your file and what you want to do with it (show the desired output ) next time. Just guessing what you want,
the total number of records is indicated by NR.
the total number of records currently is denoted by FNR.
我猜你的意思是总行数。一般来说,您应该使用
wc -l <filename>
来实现此目的。如果您想使用 awk 执行此操作,请使用
如果您只想使用 awk,请执行
I guess you mean total number of lines. In general, you should use
wc -l <filename>
for this.If you want to do this using awk, use
If you only want to use awk, do
grep -c 给出匹配记录的计数
grep -c gives the count of matching records