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

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM