Count the Number of Files in a Directory

ls -l | wc -l
  • ls: list directory contents
    • -l: list in long format
  • wc: word, line, character, and byte count
    • -l: the number of lines is written to the standard output

This command counts the number of listed lines. I find this most useful when I want to quickly see how many logs or records have been generated by a process.

Nicholas Nadeau, Ph.D., P.Eng.
Nicholas Nadeau, Ph.D., P.Eng.
Founder / Fractional CTO

Nicholas Nadeau is a fractional CTO empowering startups with next-gen technology expertise, and a passion for driving corporate innovation. Stay informed on cutting-edge hard tech trends - subscribe to my newsletter. Ready to innovate? Discover my services and accelerate your growth.

Related