Recursively counting files in a Linux directory

后端 未结 21 1105
既然无缘
既然无缘 2020-11-28 17:17

How can I recursively count files in a Linux directory?

I found this:

find DIR_NAME -type f ¦ wc -l

But when I run this it returns

21条回答
  •  孤独总比滥情好
    2020-11-28 17:25

    You can use

    $ tree
    

    after installing the tree package with

    $ sudo apt-get install tree
    

    (on a Debian / Mint / Ubuntu Linux machine).

    The command shows not only the count of the files, but also the count of the directories, separately. The option -L can be used to specify the maximum display level (which, by default, is the maximum depth of the directory tree).

    Hidden files can be included too by supplying the -a option .

提交回复
热议问题