RE: unix question

Thanks, but the wc command brings up an error message of illegal action.

Eileen

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx 
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of QuentinC
Sent: Thursday, October 07, 2010 10:39 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: unix question

> My question now is is there a way to incoorporate in this code a way to 
> count the number of the output files when I do the find ls command?  I 
> have found several commands but they appear to be only for counting the 
> files in a directory.

You may use wc -l tou count the number of lines.

Something like that :
find '/home/faserv/hrprod/cron/logs' -name '*.log' -type f -mtime +30 -print 
| wc -l
It will count the number of lines sent by the find command, which is equals 
to the number of files. Problem: you wont no more see the list itself. In 
this case you could use a temporary file. I'm not sure if it is possible to 
store the whole list (which contains a couple of lines) into a $ variable 
and proceed without any temporary file.
find '/home/faserv/hrprod/cron/logs' -name '*.log' -type f -mtime +30 -print 
 >temp.tmp
cat temp.tmp | wc -l

In fact, I think you can simplifiy your actual delete command :
find '/home/faserv/hrprod/cron/logs' -name '*.log' -type f -mtime 
+30 -delete

__________
View the list's information and change your settings at 
http://www.freelists.org/list/programmingblind

Other related posts: