![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| List files that are not directories from current directory | beni22sof | UNIX for Dummies Questions & Answers | 2 | 01-06-2009 03:44 PM |
| Viewing Directory Content as You Navigate Directories in UNIX | shelata | UNIX for Dummies Questions & Answers | 2 | 07-28-2008 01:39 AM |
| how to grep some text in a directory and as well as in its sub-directories | itsjoy2u | Shell Programming and Scripting | 4 | 04-29-2008 09:25 AM |
| How one can list only the name of directories present in the directory by using ls co | amolpatil54321 | UNIX for Dummies Questions & Answers | 2 | 02-01-2004 12:38 PM |
| list file's by size order in sepecfied directory and sub directories | ferretman | UNIX for Dummies Questions & Answers | 2 | 01-03-2002 07:55 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
how many directories and files are there in a directory
I want to know how many directories and files are there in a directory and if the sub directory have any files i also need that also .
I have done this far .... Quote:
|
|
||||
|
Code:
One way is to walk the tree. First pass finds all the directories,
then we count all the files and directories under each directory.
Grossly inefficient on a deep tree ... but short to code.
#!/bin/ksh
(
find . -type d -print|while read SUBDIR
do
COUNTER=$(find "${SUBDIR}" -print|wc -l)
echo "${SUBDIR} : ${COUNTER}"
done
) 2>&1 | pg
Last edited by methyl; 01-22-2009 at 02:15 PM.. Reason: too wide! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|