From owner-freebsd-questions Wed Apr 18 7:13:17 2001 Delivered-To: freebsd-questions@freebsd.org Received: from smtp1.cybersurf.net (smtp1.cybersurf.net [209.197.145.111]) by hub.freebsd.org (Postfix) with ESMTP id 4D58437B422 for ; Wed, 18 Apr 2001 07:13:12 -0700 (PDT) (envelope-from 01031149@3web.net) Received: from 3web.net ([209.115.233.89]) by smtp1.cybersurf.net (Netscape Messaging Server 4.15) with SMTP id GBZRHW00.4X5 for ; Wed, 18 Apr 2001 08:13:08 -0600 Received: by rockingd.calgary.ab.ca (EzMTS MTSAgent 1.22b Service) ; Wed, 18 Apr 01 08:12:15 -0600 for Received: from 3web.net (10.0.0.2) by rockingd.calgary.ab.ca (EzMTS MTSSmtp 1.23f Service) ; Wed, 18 Apr 01 07:46:11 -0600 for Received: by mandy.rockingd.calgary.ab.ca (sSMTP sendmail emulation); Wed, 18 Apr 2001 07:45:48 -0600 Date: Wed, 18 Apr 2001 07:45:45 -0600 From: Duke Normandin <01031149@3web.net> To: "Sabhanam, Srinivas (GEP)" Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Unix Shell Script Question Message-ID: <20010418074545.B216997@mandy.rockingd.calgary.ab.ca> Mail-Followup-To: "Sabhanam, Srinivas (GEP)" , freebsd-questions@FreeBSD.ORG References: <0B79B104AA51D311982F009027866BC502273D4F@SEHKG002> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="zcJ3g15gE5QbzGiw" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <0B79B104AA51D311982F009027866BC502273D4F@SEHKG002>; from "Sabhanam, Srinivas (GEP)" on Wed, Apr 18, 2001 at 01:03:07AM X-Envelope-Receiver: , Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --zcJ3g15gE5QbzGiw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Apr 18, 2001 at 01:03:07AM -0400, Sabhanam, Srinivas (GEP) wrote: > Hi, > > Could you pls. let me know how to delete files in Unix that are older than > specified days? > > Your help will be highly appreciated. > > Thanks, > Srinivas Sabhanam Hi.... The attached is what I use to 'rm' files. You can use the guts of 'purge.sh' to do what you want. Later.... -- -duke Calgary, Alberta, Canada --zcJ3g15gE5QbzGiw Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="safe_rm.sh" #!/bin/sh if (mv $* ~/tmp) then echo -e '\nfiles have been moved to your ~/tmp directory.' echo -e 'To remove them use the purge command\n' else echo 'An error occured -- files not moved!' fi --zcJ3g15gE5QbzGiw Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="purge.sh" #!/bin/sh # # A script to purge files that have been "mv"ed to the ~/tmp directory # as a result of the aliased "rm" command. Checks for files not changed # in the last 7 days and removes them. # cd ~/tmp if (/bin/find . -ctime +7 -ok rm {} \; ) then echo -e "\nfiles older than 7 days in ~/tmp have been removed." else echo "An error has occured -- files not removed!" fi --zcJ3g15gE5QbzGiw-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message