Following Number of subdirectories in a directory?, I am now trying to take into account only the directories that start with a number.
For example, if I do:
hadoop fs -ls -R foo_dir | grep "^d" | wc -l
I would try something like this:
... ls -R foo_dir | grep "/[0-9][^/]*$" -c
/ is the directory separator on linux systems.
[0-9] matches any digit.
[^/]* matches zero or more characters that are not directory separators.
$ matches the end of a line.
Hence, we match any directory or file that starts with a digit and is the last entry in the filepath.
-c arguement to
grep causes grep to print the number of matching lines.