Find the number of files older than 1 day from a dir | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Find the number of files older than 1 day from a dir

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 12-16-2010
NARESH1302 NARESH1302 is offline
Registered User
 
Join Date: Aug 2009
Last Activity: 15 September 2011, 4:53 AM EDT
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Find the number of files older than 1 day from a dir

Hello All,

I need to write a script/command which can find out the number of .csv files residing in a directory older than 1 day. The output should come with
datewise (means for each date how many files are there).

I've this command, but this command gives the total number of files. It's not listing the number of files date wise.:-(


Code:
find /stage/primed/ -mtime +1 -type f -name "*.csv" | wc -l >> /home/older1day.out 2>&1


Thanks,
Naresh

Last edited by Scott; 12-16-2010 at 07:20 AM..
Sponsored Links
    #2  
Old 12-16-2010
R0H0N's Avatar
R0H0N R0H0N is offline
Registered User
 
Join Date: Nov 2010
Last Activity: 6 May 2012, 1:49 PM EDT
Location: which ((who am i))
Posts: 302
Thanks: 6
Thanked 47 Times in 46 Posts

Code:
find /stage/primed/ -mtime +1 -type f -name "*.csv" -exec ll {} \;

Sponsored Links
    #3  
Old 12-16-2010
NARESH1302 NARESH1302 is offline
Registered User
 
Join Date: Aug 2009
Last Activity: 15 September 2011, 4:53 AM EDT
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
It's not running rohon. I tried running your command differently.

Code:
find /home/npradhan/naresh -type f -name "*.csv" -exec ll {}
find: missing argument to `-exec'

find /home/npradhan/naresh -type f -name "*.csv" -exec ll {} \;
find: ll: No such file or directory

Can you please just explain me this part- -exec ll {} \
I am confused about it.

Thanks,
Naresh

Last edited by Scott; 12-16-2010 at 07:17 AM.. Reason: Code tags
    #4  
Old 12-16-2010
R0H0N's Avatar
R0H0N R0H0N is offline
Registered User
 
Join Date: Nov 2010
Last Activity: 6 May 2012, 1:49 PM EDT
Location: which ((who am i))
Posts: 302
Thanks: 6
Thanked 47 Times in 46 Posts

Code:
find /home/npradhan/naresh -mtime +1 -type f -name "*.csv" -exec "ls -lrt" {} \;

Sponsored Links
    #5  
Old 12-16-2010
NARESH1302 NARESH1302 is offline
Registered User
 
Join Date: Aug 2009
Last Activity: 15 September 2011, 4:53 AM EDT
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
I just ran the command to test it (removing -mtime +1 option), failed.

Code:
find /home/npradhan/naresh -type f -name "*.csv" -exec "ls -lrt" {} \;
find: ls -lrt: No such file or directory
find: ls -lrt: No such file or directory


Last edited by Scott; 12-16-2010 at 07:17 AM..
Sponsored Links
    #6  
Old 12-16-2010
R0H0N's Avatar
R0H0N R0H0N is offline
Registered User
 
Join Date: Nov 2010
Last Activity: 6 May 2012, 1:49 PM EDT
Location: which ((who am i))
Posts: 302
Thanks: 6
Thanked 47 Times in 46 Posts
Try:


Code:
find /home/npradhan/naresh -type f -name "*.csv" -exec ls -l {} \;

Sponsored Links
    #7  
Old 12-16-2010
NARESH1302 NARESH1302 is offline
Registered User
 
Join Date: Aug 2009
Last Activity: 15 September 2011, 4:53 AM EDT
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
It's giving output like this-

Code:
find /home/npradhan/naresh -type f -name "*.csv" -exec ls -l {} \;
-rw-r--r-- 1 npradhan users 0 2010-12-16 11:06 /home/npradhan/naresh/jj.csv
-rw-r--r-- 1 npradhan users 0 2010-12-16 11:06 /home/npradhan/naresh/g.csv

Where as we want output like-

Code:
Date                  <directory>                      <number of files> 
2010-12-16            /home/npradhan/naresh            2

Moderator's Comments:
Start using code tags - you got a PM with a guide.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
find files older than and containing then tar. Ikon Shell Programming and Scripting 3 11-06-2009 01:36 PM
How to find files older than 30 days anushree.a Shell Programming and Scripting 4 07-08-2009 08:43 AM
Find files in a directory which are older than 2 hrs sparks Shell Programming and Scripting 8 03-21-2009 04:47 AM
find files older than a given file Shivdatta Shell Programming and Scripting 5 07-24-2006 07:25 AM
Find files older than 20 days & not use find halo98 Shell Programming and Scripting 2 05-18-2006 02:19 PM



All times are GMT -4. The time now is 07:46 AM.