AraR87
1
Guys,
I want to find the log files greather than 23 days and i want to perform 2 things here.
one is to list the files and second is to gzip the files. hope this can be done using sh -c option. but not sure the exact command.
find . -name "*.log" -mtime +23 -exec ls -la {} \;
Could you please help me on this?
Thanks,
RudiC
2
man find:
Try
find . -name "*.log" -mtime +23 -ls -exec gzip {} \;
You can have many -exec
find . -type f -name "*.log" -mtime +23 -exec ls -l {} \; -exec gzip {} \;
AraR87
5
can i use this command inside the shell script?
Sure:
#!/bin/sh
cd /dir/with/logfiles/ &&
find . ...
Don't forget to make this executable with chmod 755 shellscript
.
NB the && ensures that the find is run only when the cd was successful.