ls -1q | wc -l
ls | wc -l #Count files on current directory
ls path/to/dir | wc -l #Count files on specific directory path
ls -R|wc -l
du -a | cut -d/ -f2 | sort | uniq -c | sort -nr
find . -type d -print0 | while read -d '' -r dir; do
files=("$dir"/*)
printf "%5d files in directory %s
" "${#files[@]}" "$dir"
done
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