Solved

How to find number of files in a directory tree

Posted on 2002-05-22
6
229 Views
Last Modified: 2010-04-21
What is the easiest way to find the number of files in a directory tree with the answer showing the number of files in each sub directory?

Note the change to this question.

Cheers,

Damo
0
Comment
Question by:damohickey
6 Comments
 
LVL 38

Expert Comment

by:yuzh
ID: 7026401
If you want to find the number of regular file in a dir, type in:

   cd mydir
   find . -type f -print | wc -l

   will give the number of regular files in that dir.

   or use:


   find /full-path-to-mydir -type f -print | wc -l

0
 
LVL 6

Expert Comment

by:bira
ID: 7027310
If you want to find the number of files of all tree,
  ls -R |wc -l
0
 

Author Comment

by:damohickey
ID: 7028977
Here is the answer:

find <root of directory tree> -type d > <in_file>
cat <in_file> | while read FILE
do
echo "$FILE `ls $FILE | wc -l`" >> <out_file>
done


Cheers,

Damo
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:damohickey
ID: 7031037
Here is the answer:

find <root of directory tree> -type d > <in_file>
cat <in_file> | while read FILE
do
echo "$FILE `ls $FILE | wc -l`" >> <out_file>
done


Cheers,

Damo
0
 
LVL 20

Expert Comment

by:tfewster
ID: 7921216
No comment has been added lately, so it's time to clean up this Topic Area.
I will leave a recommendation for this question in the Cleanup topic area as follows:

- PAQ & refund points

Please leave any comments here within the next 7 days

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

tfewster
Cleanup Volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7967090
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now