Counting the number of files in Linux is made possible using the wc
command!
Count number of files and directories in current directory
Using wc
in combination with ls
, the number of files and directories in the current directory can be displayed:
|
|
Output:
|
|
To include hidden files and directories, use the -A
ls
option.
|
|
Count number of files in current directory
Using find
and wc
, the number of files in the current directory can be displayed:
|
|
-maxdepth
ensures that subdirectories are not counted.
Count number of files in current directory and subdirectories
Using find
and wc
, the number of files excluding directories can be displayed:
|
|