Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find files modified last year 2001 3

Status
Not open for further replies.

OieL

MIS
Sep 6, 2002
17
0
0
US
how can I use find to check a current dir. for files modified last year / or has a date 2001 ..

tnks
 
You could perhaps use the -mtime +nnn option to find, where nnn is the number of days since the start of this year. The command:

find . -mtime +nnn -print

should do the trick. An alternative might be to do an:

ls -la | grep 2001

to list the files with a 2001 datestamp. HTH.
 
Hi OieL,

...one had to write a script how to calculate the number of days back to a specified day which would be a sophisticated solution, but that's non-trivial...

Anyway, a quick solution (which also works properly) is:

in the directory you want to check (otherwise use absolute path names):

$ touch 1231010100 mark1
# a file with timestamp Dec 31 2000
$ touch 0101010102 mark2
# a file with timestamp Jan 01 2002
$ find . -newer mark1 ! -newer mark2
# gives you all files from 2001

HTH

mrjazz [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top