Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Linux Commands»Recursively Count Number of Files within a Directory in Linux

    Recursively Count Number of Files within a Directory in Linux

    RahulBy RahulFebruary 20, 20201 Min ReadUpdated: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

    find wc
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Install Laravel on Fedora 35/34
    Next Article How To Install OpenVPN Server on Debian 10/9

    Related Posts

    How to Search Recently Modified Files in Linux

    2 Mins Read

    Bash Printf Command

    Updated:December 23, 20212 Mins Read

    (Resolved) -bash: /bin/mv: Argument list too long

    Updated:January 13, 20222 Mins Read

    Tee Command in Linux with Examples

    4 Mins Read

    How to Scan Open Ports with Nmap

    5 Mins Read

    Handling filenames with spaces in Linux

    3 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    • (Resolved) Please install all available updates for your release before upgrading
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.