Max Asked: 2009-07-21 00:42:54 +0800 CST2009-07-21 00:42:54 +0800 CST 2009-07-21 00:42:54 +0800 CST How to count all subfolders in an directory? 772 How can I count how many folders (including subfolders) I have under an specific folder? linux count directory find 2 Answers Voted Best Answer Dan Carley 2009-07-21T00:46:18+08:002009-07-21T00:46:18+08:00 Use find to select the directories and wc to count them. find <directory> -mindepth 1 -type d | wc -l dyasny 2009-07-21T01:56:21+08:002009-07-21T01:56:21+08:00 tree -d | grep directories | awk -F' ' '{print $1}'
Use
find
to select the directories andwc
to count them.tree -d | grep directories | awk -F' ' '{print $1}'