The UNIX Forums
"Join the Network of UNIX System Users"


 
Subject: number of files in a particular directory
dewouter
Newbie
Rank: 1



UID 115
Digest Posts 0
Credits 0
Posts 63
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:42 AM  Profile | P.M. 
number of files in a particular directory



number of files in a particular directory




hi,

i am new to unix shell scripting.i am using korn shell.
i need to find if there are any files in a particular directory.first i need to find the number of files in the directory.if the file count is greater than 0 then i have to print the file names in a textfile and send an email to the user.

can anyone help me please.

thanks,


Top
Ajeet
Newbie
Rank: 1



UID 43
Digest Posts 0
Credits 0
Posts 8
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:42 AM  Profile | P.M. 
dbplatha,
see if this works for you:

code:

typeset -i mtotfiles
for mfile in `find . -type d`
do
  mtotfiles=`ls -1 $mfile | wc -l`
  if [ $mtotfiles -gt 0 ]; then
    echo "mtotfiles = "$mtotfiles" greater than zero"
Top
 

 

All times are GMT, the time now is Mar 12, 2010 07:44 AM

Powered by Discuz! 5.0.0  © 2001-2006 UNIX Forums
Processed in 0.005256 second(s), 8 queries

Clear Cookies - Contact Us - UNIX Help - Archiver - WAP