Shell脚本统计文件行数的方法
******************Shell脚本统计文件行数的方法***********
获取单个文件行数,文件:test.sh,行数:5。
[root@BLJ JD]# awk '{print NR}' test.sh|tail -n1
5
[root@BLJ JD]# awk 'END{print NR}' test.sh
5
[root@BLJ JD]# grep -n "" test.sh|awk -F: '{print '}|tail -n1
5:5
[root@BLJ JD]# sed -n '$=' test.sh
5
[root@BLJ JD]# wc -l test.sh #行数-1
4 test.sh
[root@BLJ JD]# cat test.sh |wc -l #行数-1
4
***********************************************************