网络营销电子商务研究中心

网络营销电子商务研究中心 (https://www.0058.net/index.php)
-   Linux (https://www.0058.net/forumdisplay.php?f=78)
-   -   How to count all files inside a folder, its subfolder and all (https://www.0058.net/showthread.php?t=5223)

Kaleva 2015-08-18 03:40 PM

How to count all files inside a folder, its subfolder and all
 
How to count all files inside a folder, its subfolder and all . The count should not include folder count

I have a really deep directory tree on my Linux box. I would like to count all of the files in that path, including all of the subdirectories.

For instance, given this directory tree:
/home/blue
/home/red
/home/dir/green
/home/dir/yellow
/home/otherDir/

Sabin 2015-08-18 03:41 PM

find . -type f | wc -l

Explanation:
find . -type f finds all files ( -type f ) in this ( . ) directory and in all sub directories, the filenames are then printed to standard out one per line.

This is then piped | into wc (word count) the -l option tells wc to only count lines of its input.

Together they count all your files.

Quakertown 2015-08-18 03:42 PM

Find all files under home and count them using wc. This works on linux:

find home -type f | wc -l


All times are GMT +8. The time now is 04:06 AM.

Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.