I have to count the total number of directories that are in the given directory (note that these are subdirectories).
I know how to count for files but am having trouble counting the directories for my script.
directory
I have to count the total number of directories that are in the given directory (note that these are subdirectories).
I know how to count for files but am having trouble counting the directories for my script.
Best Answer
In a slightly robuster variation of @rahul's comment:
will print '1' for each directory in the current one that is not the current one (
-mindepth 1
), and then we count the 1s. This will cope with directory names that contain newlines.