• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

Recursively Count Number of Files within a Directory in Linux

Written by Rahul, Updated on March 20, 2020

Sometimes we need to find actual number of files available under a directory. But it directory contains multiple sub directories. Then it is hard to manually count number of files within a directory in Linux system using command line.

find DIR_NAME -type f | wc -l
  • find – Is a Linux/Unix command
  • DIR_NAME – A directory path to search for. Use dot (.) to start search from current directory
  • -type f – Search for files only (do not include directories)
  • Pipe (|) – Pipe sends output of one command as input to other command
  • wc -l – Count number of lines in result

Count files within current directory

Use the following command to count the number of available files under the current directory. Here dot (.) denotes to the current directory.

find . -type f | wc -l

Recursively Count Number of Files

Count files in specific directory

To count files under any other directory use the following command. Here the command will find all files under the /backup directory and print total count on screen.

find /backup -type f | wc -l

Recursive count files in linux command

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How To Install Python 3.9 on Ubuntu 18.04 0
  • How to Use AppImage on Linux (Beginner Guide) 2
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy