I'm looking for a script that find all files older than 1st Jan 2010. The follow开发者_运维百科ing 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
Just use the "find" command. There are several flags that allow you to filter file by last modification time, such as -newer, -mmin and -mtime. Do a "man find" for more details.
精彩评论