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.:frowning:

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

Thanks,
Naresh

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

It's not running rohon. I tried running your command differently.

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

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

I just ran the command to test it (removing -mtime +1 option), failed.

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

Try:

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

It's giving output like this-

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-

Date                  <directory>                      <number of files> 
2010-12-16            /home/npradhan/naresh            2
find /home/npradhan/naresh -type f -name "*.csv" -exec ls -l {} \; | awk '{print $6"<tab>"$8}' | sed 's/\/.*$//g' > tempFile

cat tempFile | cut -f2 | uniq | while read line
do
     echo "$line<tab>"`grep "$line" tempFile | wc -l`
done

I just ran this command with slight modification, it ran successfully. Only thing it's not being able to give the directory name.

find /home/npradhan/naresh -type f -name "*.csv" -exec ls -l {} \; | awk '{print $6" "$8}' | sed 's/\/.*$//g' > tempFile
 
cat tempFile | cut -f2 | uniq | while read line
do
     echo "$line   -    "`grep "$line" tempFile | wc -l`
done
 

Output-

2010-12-16   -    2
 

Is there any way to list the directory name also?

echo `grep "$line" tempFile`" - "`grep "$line" tempFile | wc -l`

This does not give the desired output like the following:

Date                  <directory>                      <number of files> 


2010-12-16            /home/npradhan/naresh            2