ls | wc -l #Count files on current directory
ls path/to/dir | wc -l #Count files on specific directory path
ls -R|wc -l
# Use this command
ls /etc | wc -l
# replace /etc with the path to the directory you want to work with
du -a | cut -d/ -f2 | sort | uniq -c | sort -nr
du -a | cut -d/ -f2 | sort | uniq -c | sort -nr
find -maxdepth 1 -type d | while read -r dir; do printf "%s: " "$dir"; find "$dir" -type f | wc -l; done
tree | tail -1
output
10 directories, 294 files
#Find all File's name that starts with chapter-CHAPTER in a Directory
count=$(echo $PATH |ls | grep '^moby-CHAPTER' | wc -l)
echo $count chapters