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