關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • Linux: 列出目錄及檔案數量

    Posted on March 9th, 2006 Sam Tang No comments

    用 ls 指令會列出目錄下的內容,如果想知道目錄下有多少檔案及多少目錄,可以輸入以下指令:

    顯示檔案數目:
    ls -la |grep "^-" |awk ‘END {print "Number of files: " NR}’

    顯示目錄數目:
    ls -la |grep “^d” |awk ‘END {print "Number of directories: " NR}’


    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word