tapia
1
Hi all
I have directory /tmp and i have logs are written in it every 18 to 20 hours in date format.
now i need write some if condition which can find which files came into /tmp dir with name start from LOG_`date`.log in last 24 hours.
can somebody help me on this.
Look at mtime switch in find
Files created in within 24 hrs
find /tmp -name "LOG_*.dat" -mtime -1
Files created in after 24 hrs
find /tmp -name "LOG_*.dat" -mtime +1
methyl
3
LOG_`date`.log
Off topic. This is not a good name for a file. It will contain spaces, colons and other unwanted characters.
A better technique is:
YYYYMMDD="`date +%Y%m%d`" # Reversed date yyyymmdd
LOG_${YYYYMMDD}.log
Much easier to deal with in subsequent scripts. Also comes out in date order in a basic "ls".