4 /bin/ls -1fR "$dir" | grep -v "^$" | grep -v "^\.$" | grep -v "^\.\.$" | grep -v ".*:$" | wc -l
6 # patterns that remove files from being counted, above:
8 # ^$ -- all blank lines
9 # ^\.$ -- all lines with just a dot (current directory)
10 # ^\.\.$ -- all lines with just two dots (parent directory)
11 # .*:$ -- all lines that end with a colon (directory heading from recursive ls)