LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-16-2009, 09:01 AM   #1
cy163
LQ Newbie
 
Registered: Jun 2007
Posts: 23

Rep: Reputation: 15
how to list the number of files in serveral sub-directories


Hello ALL,


I would like to learn how many files there are in respective sub-directories which are under a specified directory with one command.



Thanks
 
Old 05-16-2009, 09:54 AM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,036

Rep: Reputation: 96
Might be stretching the "one command" part, and I'm not entirely sure of what you are after, but how about:
Code:
echo "$(find . -type f|wc -l) files and $(find . -type d|wc -l) directories"
 
Old 05-16-2009, 12:29 PM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
In one command is not so easy. If you don't restrict solution only to one-liners:
Code:
for dir in $(find . -mindepth 1 -type d)
do
  printf "%5d  %-40s\n" $(find $dir -maxdepth 1 -type f | wc -l) $dir
done
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to list & sort directories by number of items they contain? Mountain Linux - Software 5 04-27-2009 09:10 AM
Trouble with a script to manipulate files within a large number of directories zorblart Programming 1 01-10-2009 03:11 AM
List total number of directories paraiso Linux - Newbie 5 04-18-2005 05:04 AM
Number of files and directories ALF Linux - Software 4 06-11-2003 11:34 AM
Why cannot i start serveral X window by startx --:number(in diffrent consoles) whepin Linux - Newbie 2 12-20-2001 07:27 PM


All times are GMT -5. The time now is 10:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration