Hi,
I am using the following command to extract any log files that are older than 3 days using the following command.
find DIR/LOGDIR -type f -mtime +3 |grep LOG > log_list.out
The results are
DIR/LOGDIR/1.LOG
DIR/LOGDIR/2.LOG
DIR/LOGDIR/3.LOG
DIR/LOGDIR/4.LOG
How do inculde (basename or awk ??) to extract just the file name instead of the complete directory like in log_list.out file.
1.LOG
2.LOG
3.LOG
4.LOG
Thanks all.
aigles
2
You can do something like that :
find DIR/LOGDIR -type f -mtime +3 -name '*LOG*' | sed 's_.*/__' > log_list.out
Jean-Pierre.
You could also do this:
find DIR/LOGDIR -type f -mtime +3 -name '*LOG*' -exec basename {} \;
but this runs "basename" for each file. The "sed" command above is probably several hundred milliseconds faster.
if you have GNU find
find /path -type f -mtime +3 -name '*LOG*' -printf "%f\n"