Find the answer to your Linux question:
Results 1 to 3 of 3
Hi all... I have a directory called dbrn . This directory contains an unknown number of subdirectories which in turn contain an unknown number of files. What I want to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2011
    Posts
    1

    Question Command for total number of files (and size) across subdirectories?


    Hi all...

    I have a directory called dbrn. This directory contains an unknown number of subdirectories which in turn contain an unknown number of files.


    What I want to know is:

    How many files with extention .ABC can be found in /dbrn across all subdirecties, and what is the total size for all files with extention .ABC

    I know how to do this if all files are in the root folder, but not if the files are scattered across subdirectories.

    Anyone any idea on what command (with what parameters) to use to accomplish the above?

    Thanx!

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,348
    Try this
    Code:
    find /dbrn -type f -name "*.ABC" -print0 | du -c --files0-from=-
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Sep 2007
    Location
    Silver Spring, MD
    Posts
    95

    Another alternative that gives just the number of the file

    Quote Originally Posted by Irithori View Post
    Try this
    Code:
    find /dbrn -type f -name "*.ABC" -print0 | du -c --files0-from=-
    ======================
    Quote Originally Posted by tdsan View Post
    Or if you are just interested in the total size, use this
    Code:
    find /dbrn -type f -name "*.ABC" -exec ls -l {} \; | awk '{ SUM += $5 } END { print SUM/1024 }'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •