From owner-freebsd-questions Wed Jan 16 7:53:36 2002 Delivered-To: freebsd-questions@freebsd.org Received: from web20108.mail.yahoo.com (web20108.mail.yahoo.com [216.136.226.45]) by hub.freebsd.org (Postfix) with SMTP id 45E6937B419 for ; Wed, 16 Jan 2002 07:53:29 -0800 (PST) Message-ID: <20020116155328.17373.qmail@web20108.mail.yahoo.com> Received: from [24.100.124.207] by web20108.mail.yahoo.com via HTTP; Wed, 16 Jan 2002 07:53:28 PST Date: Wed, 16 Jan 2002 07:53:28 -0800 (PST) From: ann kok Subject: Re: crontab to backup mail in date format To: Giorgos Keramidas Cc: Jan Grant , questions In-Reply-To: <20020116033309.GB25005@hades.hell.gr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Dear Giorgos Thank you But I tried your command. but got the following problem Pls help again [root@mail /tmp]# touch mail.2001.01.12.tar.gz [root@mail /tmp]# touch mail.2001.01.13.tar.gz [root@mail /tmp]# touch mail.2001.01.14.tar.gz [root@mail /tmp]# touch mail.2001.01.15.tar.gz [root@mail /tmp]# touch mail.2001.01.16.tar.gz [root@mail /tmp]# ls -l mail* -rw-r--r-- 1 root root 0 Jan 16 11:45 mail.2001.01.12.tar.gz -rw-r--r-- 1 root root 0 Jan 16 11:45 mail.2001.01.13.tar.gz -rw-r--r-- 1 root root 0 Jan 16 11:45 mail.2001.01.14.tar.gz -rw-r--r-- 1 root root 0 Jan 16 11:45 mail.2001.01.15.tar.gz -rw-r--r-- 1 root root 0 Jan 16 11:45 mail.2001.01.16.tar.gz [root@mail /tmp]# ls -1 mail.*.tar.gz | sort -3 | sed -e '1,3d' sort: when using the old-style +POS and -POS key specifiers, the +POS specifier must come first Try `sort --help' for more information. --- Giorgos Keramidas wrote: > On 2002-01-16 05:08:22, Giorgos Keramidas wrote: > > > > Sort backup archives by date, and erase everything > that is older than > > 3 days. If you have files called: > > > > % ls -1 mail.* > > mail.2002.01.08.tar.gz > > mail.2002.01.09.tar.gz > > mail.2002.01.10.tar.gz > > mail.2002.01.11.tar.gz > > mail.2002.01.12.tar.gz > > > > and you want to erase all but the 3 last, you can > use commands like: > > > > % ls -1 mail.*.tar.gz | sort -3 | sed -e '1,3d' > > Of course that should read: sort -r > > Bleh, I should stop replying to mail after 03:00 am. > > -- > Giorgos Keramidas . . . . . . . . . > keramida@{ceid.upatras.gr,freebsd.org} > FreeBSD Documentation Project . . . > http://www.freebsd.org/docproj/ > FreeBSD: The power to serve . . . . http://www.freebsd.org/ __________________________________________________ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message