ls | wc -l
#count files in a directory faster with:
ls -f | wc -l
#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
find /path/to/directory | wc -l