Date: Wed, 18 Apr 2001 07:45:45 -0600 From: Duke Normandin <01031149@3web.net> To: "Sabhanam, Srinivas (GEP)" <Srinivas.Sabhanam@gepex.ge.com> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Unix Shell Script Question Message-ID: <20010418074545.B216997@mandy.rockingd.calgary.ab.ca> In-Reply-To: <0B79B104AA51D311982F009027866BC502273D4F@SEHKG002>; from "Sabhanam, Srinivas (GEP)" on Wed, Apr 18, 2001 at 01:03:07AM References: <0B79B104AA51D311982F009027866BC502273D4F@SEHKG002>
next in thread | previous in thread | raw e-mail | index | archive | help
--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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010418074545.B216997>