Facebook X (Twitter) Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook X (Twitter) Instagram
    TecAdmin
    You are at:Home»Linux Commands»Recursively Count Number of Files within a Directory in Linux

    Recursively Count Number of Files within a Directory in Linux

    By RahulMarch 20, 20201 Min Read

    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

    Related Posts

    How to Ignore SSL Certificate Check with Wget

    How to Ignore SSL Certificate Check with Curl

    echo Command in Linux with Practical Examples

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Difference Between Full Virtualization vs Paravirtualization
    • Virtualization vs. Containerization: A Comparative Analysis
    • Using .env Files in Django
    • Using .env File in FastAPI
    • Setting Up Email Notifications for Django Error Reporting
    Facebook X (Twitter) Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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