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