In Java code, I want to connect to a directory in HDFS, learn the number of files in that directory, get their names and want to read them. I can already read the files but I co
To do a quick and simple count, you can also try the following one-liner:
hdfs dfs -ls -R /path/to/your/directory/ | grep -E '^-' | wc -l
Quick explanation:
grep -E '^-' or egrep '^-': Grep all files: Files start with '-' whereas folders start with 'd';
grep -E '^-'
egrep '^-'
wc -l: line count.
wc -l