Count Files in a Directory

Tips of Linux

$ ls -lR ./collection | grep "^-" | wc -l
$ ls -lR ./collection | grep "^d" | wc -l
$ ls -l ./collection | grep "^-" | wc -l
  • R Recursive subdirectory.
  • ^- Indicates a file.
  • ^d Indicates a directory.
  • wc -l Count the number of lines of output information.
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus