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.
find /stage/primed/ -mtime +1 -type f -name "*.csv" | wc -l >> /home/older1day.out 2>&1
Thanks,
Naresh
system
December 16, 2010, 6:04am
2
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
system
December 16, 2010, 6:13am
4
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
system
December 16, 2010, 6:21am
6
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
system
December 16, 2010, 6:45am
8
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?
system
December 16, 2010, 7:15am
10
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