how to find files & subfolders inside a folder using command
I have taken clue from previous post & come up with simplest way
Finding number of files in a folder
find . -type f | wc -l
this means output of find comand (which is only files no directories)is sent to wc which counts number of lines i.e number of files
Finding number of subfolders in a folder
(1)find . -type d | wc -l
This will give number of subfolders+1 because current folder also gets included.Note that the folders inside subfolders are also included in count.
(2)If you want to see only number of folders in current folder then
find . -maxdepth 1 -type d | wc -l
Here output is numberof subfolders+1
NOTE:folders inside subfolders not considered.
If this information helps you please thank me by pressing thumbs up button.Happy hacking.
Last edited by sumeet inani; 10-28-2009 at 08:52 AM.
|