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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find the number of files older than 1 day from a dir
# 1  
Old 12-16-2010
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 08:20 AM..
# 2  
Old 12-16-2010
Code:
find /stage/primed/ -mtime +1 -type f -name "*.csv" -exec ll {} \;

R0H0N
# 3  
Old 12-16-2010
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 08:17 AM.. Reason: Code tags
# 4  
Old 12-16-2010
Code:
find /home/npradhan/naresh -mtime +1 -type f -name "*.csv" -exec "ls -lrt" {} \;

R0H0N
# 5  
Old 12-16-2010
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 08:17 AM..
# 6  
Old 12-16-2010
Try:

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

R0H0N
# 7  
Old 12-16-2010
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:
Mod Comment Start using code tags - you got a PM with a guide.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep files older than 1 day

I thought that this would work for grep'ing files older than 1 day. ps -o etime,pid,user,args -e|awk '/^+-/'|sort -t- -n -k 1,1 |grep qdaemon |grep /usr/bin/ksh But, it is not grep'ing any of files (i.e. below) older than 1 day. d_prod 33757970 61999560 0 Oct 27 - 0:00... (8 Replies)
Discussion started by: Daniel Gate
8 Replies

2. Shell Programming and Scripting

Find processes older than 1 day

// AIX 6.1 I need to extract PIDs of ps -ef |grep /usr/lib/lpd/pio | awk '{print $2}' ps -ef |grep qdaemon |grep /usr/bin/ksh | awk '{print $2}' that are older than 1 day. I know find . -type f -mtime +1, but it doesn't work for PIDs. Please let me know how to get the PIDs older than... (1 Reply)
Discussion started by: Daniel Gate
1 Replies

3. Shell Programming and Scripting

Sftp - 1 day older files count

Need to write a shell script on AIX box which will connect to different servers using SFTP and get the file count of only 1 day older files. (purging list) How to achieve this? On local server we can use: find <path> -type f -mtime +1 But how to do it in case of SFTP? Please advise. Thanks... (9 Replies)
Discussion started by: vegasluxor
9 Replies

4. Shell Programming and Scripting

How archive the older than 30 day files to another unix server

I need to archive the older than 30 day file to another uinx server.I have wrote the below uinx script. for LOOK_DIR in /TempFiles do for FILE in `find ${LOOK_DIR} -mtime -30 -exec ls {} \;` do echo ${FILE} >> file_list ## This file will have the list of files copied and... (12 Replies)
Discussion started by: murari83.ds
12 Replies

5. UNIX for Dummies Questions & Answers

List files older that 7 days in a dir, excluding all subdirs

Hi, I would like to list all files, older than 7 days, in a directory, but exclude all subdirectories in the find command. If I use find . -type f -mtime +7 all files in the subdirs are also included. How can I exclude them? Regards, JW (6 Replies)
Discussion started by: jwbijl
6 Replies

6. Shell Programming and Scripting

KSH - Find paths of multiple files in CC (dir and sub-dir))

Dear Members, I have a list of xml files like abc.xml.table prq.xml.table ... .. . in a txt file. Now I have to search the file(s) in all directories and sub-directories and print the full path of file in a output txt file. Please help me with the script or command to do so. ... (11 Replies)
Discussion started by: Yoodit
11 Replies

7. Shell Programming and Scripting

A script to find dir, delete files in, and then del dir?

Hello!! I have directories from 2008, with files in them. I want to create a script that will find the directoried from 2008 (example directory: drwxr-xr-x 2 isplan users 1024 Nov 21 2008 FILES_112108), delete the files within those directories and then delete the directories... (3 Replies)
Discussion started by: bigben1220
3 Replies

8. Shell Programming and Scripting

need to move files of particular day from one dir to another dir

Hi, I have hundered's of files of the name CMP_PORT_IN_P200903271623042437_20090328122430_err.xml in error directory of todays date ie 20090328 and in the file name 5th field specifies date only now i want to move all files of 20090328 to another directory i.e reprocess directory. So... (3 Replies)
Discussion started by: ss_ss
3 Replies

9. Shell Programming and Scripting

Deleting / finding files older than X days missess a day

Hi When trying to find and delete files which are, say, 1 day, the find command misses a day. Please refer the following example. xxxd$ find . -type f -ctime +1 -exec ls -ltr {} \; total 64 -rw-rw-r-- 1 oracle xxxd 81 Apr 30 11:25 ./ful_cfg_tmp_20080429_7.dat -rw-rw-r-- 1... (4 Replies)
Discussion started by: guruparan18
4 Replies

10. Shell Programming and Scripting

Find files older than 20 days & not use find

I need to find files that have the ending of .out and that are older than 20 days. However, I cannot use find as I do not want to search in the directories that are underneath the directory that I am searching in. How can this be done?? Find returns files that I do not want. (2 Replies)
Discussion started by: halo98
2 Replies
Login or Register to Ask a Question