I'm looking for a script that find all files older than 1st Jan 2010. The following isn't working for me -
date-of-my-file = $(date -r /my-file +%F)
if [ $date-of-my-file -nt "2010-01-01" ]
then
echo "Yes"
else
echo "No"
fi
Any help will be appreciated. P.S: touch command is not working on my box with deprecated Linux.
Here's a one-liner:
find <dir> -not -newermt 2010-01-01
This finds all files modified before the specified date. Do a man find and look at the options for -newerXY if you want to use something besides modified date.
you need to use shell commands find with newer option.
it works like: you create a file with timestamp 1.1.2010 and then compare all files with this timestamp
touch -t 01010000 /tmp/timestamp<br>
find ~ -newer /tmp/timestamp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With