Issue
I would like to count ONLY the directories of a folder. For example:
- Main_folder
Folder
- Folder_1
- Another_file
- Folder_1
Folder
File_2
- Another_file
File_3
- Another_file - Another_file
I need a command that counts only the bold files. In this case the result would be "3".
Is this possible?
Thanks!
Solution
You can try this. Hope it works
find <path> -type d -printf '%d\n' | grep 2 | wc -l
%d File's depth in the directory tree; 0 means the file is a starting-point.
Answered By - nhatnq Answer Checked By - Marilyn (WPSolving Volunteer)