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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

removing old files

Status
Not open for further replies.

jalge2

Technical User
Feb 5, 2003
105
US
I've got a bunch of history files with this naming convention.

hislog.20030301
hislog.20030228

As you can see, these are history files with a date on the end as an expression. I'm trying to remove all files that are 7 days or older using this expression at the end of the file name. I'm getting an error of a test unknown operator on line 10. Please help. Here is my script.


#!/bin/ksh

##Variables##
date1=`date +%Y%m%d`
date2=`expr $date1`
less=$(($date2 - 7))

##Script##
cd /dso/mis/scripts/delhislog
if [ *.* =< *.$less1 ]

then rm
fi
exit

I'm having problems with my if statement and was wondering if someone could help me out. Thanks a lot.

Jason Alge


 
Your idea won't work for any day less than 7th day of every month.
Use find :
find /dirname -name &quot;hislog.2003????&quot; -mtime -7 -exec rm {} \;

That'll remove all for this year > 7 days old.
HTH
Dickie Bird (:)-)))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top