linux awk命令统计多个文件的总行数

1、测试数据

root@DESKTOP-1N42TVH:/home/test# ls
test.txt  test2.txt
root@DESKTOP-1N42TVH:/home/test# cat test.txt
a 3 d
s 1 j
z c m
q e i
3 4 k
h f 3
root@DESKTOP-1N42TVH:/home/test# cat test2.txt
a 3 d
s 1 j
z c m
q e i
3 4 k
h f 3
root@DESKTOP-1N42TVH:/home/test# awk '{print NR}' test.txt test2.txt  ## 生成两个文件总的索引
1
2
3
4
5
6
7
8
9
10
11
12
root@DESKTOP-1N42TVH:/home/test# awk 'END{print NR}' test.txt test2.txt   ## 统计两个文件的总行数
12

root@DESKTOP-1N42TVH:/home/test# awk '{print FNR}' test.txt test2.txt
1
2
3
4
5
6
1
2
3
4
5
6

 

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。