Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash script count directories in directory

#count dirs in current dir.  ex. dir tree:  /a/b/c, /a/c/b, /a/d/
dirCount() { echo $(find "$1"* -maxdepth 0 -type d | wc -l); }
declare -l _path="/a/"
echo $(dirCount "$_path") #outputs: 3
 
PREVIOUS NEXT
Tagged: #bash #script #count #directories #directory
ADD COMMENT
Topic
Name
7+1 =