Linux: 列出目錄及檔案數量
用 ls 指令會列出目錄下的內容,如果想知道目錄下有多少檔案及多少目錄,可以輸入以下指令:
顯示檔案數目:
ls -la |grep "^-" |awk ‘END {print "Number of files: " NR}’
顯示目錄數目:
ls -la |grep “^d” |awk ‘END {print "Number of directories: " NR}’
[root@mail /]# ls -la |grep "^-" |awk 'END {print "Number of files:" NR}'
Number of files:5
You have new mail in /var/spool/mail/root
[root@mail /]# ls -la home |grep "^-" |awk 'END {print "Number of files:" NR}'
Number of files:2
[root@mail /]# ls -la home |grep "^d" |awk 'END {print "Number of files:" NR}'
Number of files:526
沒有留言:
張貼留言