The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
read list of filenames from text file and remove these files in multiple directories fxvisions Shell Programming and Scripting 5 08-07-2008 04:59 PM
how to list directories only yodadbl07 UNIX for Dummies Questions & Answers 3 04-26-2006 05:48 AM
How to list only directories? videsh77 UNIX for Dummies Questions & Answers 4 01-09-2006 10:10 AM
List directories malaymaru UNIX for Dummies Questions & Answers 3 09-25-2005 10:54 AM
List specific files from directories Filippo Shell Programming and Scripting 4 02-17-2005 03:56 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 3.00 average. Display Modes
  #1 (permalink)  
Old 07-07-2008
psalas psalas is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 19
Cool List directories and files

I want to count how many levels there are under a directory. I repeat level.

Also how i count only all the files in a directoy ( all files of all directories of all leves down!)

and how can i count only all the directories under a directory (including subdirectories, all levels down)

Please someone help me!!!
  #2 (permalink)  
Old 07-07-2008
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
Quote:
Originally Posted by psalas View Post
and how can i count only all the directories under a directory (including subdirectories, all levels down)
Code:
find . -mindepth 1 -type d | wc -l
  #3 (permalink)  
Old 07-07-2008
spirtle spirtle is offline
Registered User
  
 

Join Date: Jun 2008
Location: Scotland
Posts: 150
To count all the files,
Code:
find dir -type f|wc -l
For the greatest subdirectory depth you could do something like the following in bash
Code:
dir=path/to/some_directory
m=0
for path in `find $dir -type d`
do
  n=`echo $path|sed s,$dir/,,|awk -F / '{print NF}'`
  [ $n -gt $m ] && m=$n
done
echo $m
Closed Thread

Bookmarks

Tags
find

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:21 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0