Korn shell script

January 23, 2006 at 23:00:42
Specs: Solaris, 2500
Hi, anyone have any korn shell script that do a recursive files count from parent directory and below?
example: /etc/ls -l|wc -l
/etc/rc2.d/ls -l|wc -l
/etc/rc2.d/a/ls -l |wc -l


See More: Korn shell script

Report •

January 24, 2006 at 07:28:06
use find:

# untested
find dir1 dir2 -type f -print|wc -l

Report •

January 24, 2006 at 19:37:00
thanks, the find command sum up all the directories files within the dir1.
I looking for something that can count and list individual directory files recursively.
Wanted to know numbers of files kept in the directories and not knowing how many child directories are there within a parent directory.

Report •

January 24, 2006 at 20:41:02
The find command can look at more than one directory at a time. Sorry, but I'm not understanding your problem

Report •

Related Solutions

January 24, 2006 at 22:08:38
I'm actually wanted to count the number of files in each of the directory. Let's say dir1 contain sub-directories /dir1/dir1a and /dir/dri1b, the result will be something like these:
/dir1 - 333 files
/dir1/dir1a - 500 files
/dir1/dir1b - 666 files


Report •

January 25, 2006 at 18:52:06
Ok, I understand. You want to serch just the current directory and none of the child driectories below. The GNU version of find (read Linux) has a maxdepth option. Since you're on Solaris, you probably don't have it.

You need a script that does the same, so check out this URL:


This article covers a few miscellaneous tips. The one you are interested in is:

A Method for Executing find on Files in the Current Working Directory

Report •

Ask Question