How to count the files in a directory using Bash Command


You can count the number of files within a directory using the combination of two bash commands - find and wc.

Let's take a look at an example.

$ find ~/Desktop/ -type f | wc -l

13

As you can see, the number of files on my desktop directory has been counted as 13.

Find the Count of files in a directory using bash command

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap