Operating System - HP-UX
1833059 Members
2934 Online
110049 Solutions
New Discussion

Find files older than 2003

 
SOLVED
Go to solution
Jagadesh_2
Regular Advisor

Find files older than 2003

Hi,

Please let me know how to find files in a particular filesystem which is older than year 2003.

Thanks
Jagadesh
10 REPLIES 10
Pete Randall
Outstanding Contributor

Re: Find files older than 2003

Use the touch command to create a reference file with the proper date and then use find with the not newer option "! -newer".


Pete

Pete
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Find files older than 2003

Since you are seeking for files older than 2003, you will get a year in "ls -l".

It doesn't show the year for files less than 6 months old.

Not sure of the syntax but try.

ls -l | awk '{if ($8<2003) print $0}'
Vibhor Kumar Agarwal
Alessandro Pilati
Esteemed Contributor

Re: Find files older than 2003

Jagadesh,
Put there 2 rows in a script and launch it:

let days=`date +'%j'`+730
find /etc -mtime +$var -exec ll {} \+

Regards,
Alex
if you don't try, you'll never know if you are able to
Alessandro Pilati
Esteemed Contributor

Re: Find files older than 2003

Sorry Jagadesh,
in the commands above I wrote /etc, instead of this put the path you want to check.

Rgds,
Alex
if you don't try, you'll never know if you are able to
Alessandro Pilati
Esteemed Contributor

Re: Find files older than 2003

Vibor,
your command doesn't consider that in the 8th fiels of "ls -l" for files modified in the current year, the OS put the modification hour, and is not recursive ;-))
if you don't try, you'll never know if you are able to
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Find files older than 2003

Good point,

Recursive is not a problem, we can simply use a loop or the -R option of ls.

But i have to check for date.

Gotcha,

Just in // of awk give a negation of : for the 8 field.
Vibhor Kumar Agarwal
john korterman
Honored Contributor
Solution

Re: Find files older than 2003

Hi,

just adding details to the first posting:

# touch 0101000003 myfile
# find /dilledaller -type f ! -newer ./myfile -exec ls -l {} \;


regards,
John K.
it would be nice if you always got a second chance
A. Clay Stephenson
Acclaimed Contributor

Re: Find files older than 2003

Yet another use for caljd.sh:

DAYS=$(( $(caljd.sh) - $(caljd.sh 1 1 2003) ))
find . -type f -mtime +${DAYS} -print
If it ain't broke, I can fix that.
Jagadesh_2
Regular Advisor

Re: Find files older than 2003

Thanks for all your response.
touch -t 0301010000 /tmp/time02

nohup find /u04 ! -newer /tmp/newfile.txt -size +5000000c -exec ls -l {} \;

this works.
Jagadesh_2
Regular Advisor

Re: Find files older than 2003

thanks