linux 中统计文件的行数,不显示文件名
001、cat + wc -l
[root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt ## 测试文件 1 2 3 4 5 6 7 8 9 10 [root@PC1 test]# cat a.txt | wc -l ## 输出文件的行数 10

002、sed -n "$="
[root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt 1 2 3 4 5 6 7 8 9 10 [root@PC1 test]# sed -n "$=" a.txt ## 统计文件的行数,不显示文件名 10

003、wc -l <file
[root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt 1 2 3 4 5 6 7 8 9 10 [root@PC1 test]# wc -l <a.txt ## 输出文件的行数 10


浙公网安备 33010602011771号