From owner-freebsd-questions Mon Jan 21 12:47:57 2002 Delivered-To: freebsd-questions@freebsd.org Received: from web20103.mail.yahoo.com (web20103.mail.yahoo.com [216.136.226.40]) by hub.freebsd.org (Postfix) with SMTP id A31B537B446 for ; Mon, 21 Jan 2002 12:47:23 -0800 (PST) Message-ID: <20020121204723.40222.qmail@web20103.mail.yahoo.com> Received: from [24.100.124.207] by web20103.mail.yahoo.com via HTTP; Mon, 21 Jan 2002 12:47:23 PST Date: Mon, 21 Jan 2002 12:47:23 -0800 (PST) From: ann kok Subject: Re: crontab to backup mail in date format To: Giorgos Keramidas Cc: questions@FreeBSD.ORG In-Reply-To: <20020117015810.GB20298@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 Re: Sed for keep 3 days backup I would like to know the meaning of sed -e 1,3d and discoverd that the script doesn't work for the following What's wrong myself? please help again TIA AFTER SED [root@mail /backup]# ls -1 *backmail.tar.gz | sort -r | sed -e 1,3d 221428 2002-01-17backmail.tar.gz 220500 2002-01-13backmail.tar.gz 217924 2001-12-31backmail.tar.gz 215380 2002-01-15backmail.tar.gz 214400 2002-01-16backmail.tar.gz 187880 2002-01-07backmail.tar.gz 0 2002-01-20backmail.tar.gz ORIGINAL DATA [root@mail /backup]# ls -1 *backmail.tar.gz 99468 2001-11-22backmail.tar.gz 217924 2001-12-31backmail.tar.gz 187880 2002-01-07backmail.tar.gz 220500 2002-01-13backmail.tar.gz 215380 2002-01-15backmail.tar.gz 214400 2002-01-16backmail.tar.gz 221428 2002-01-17backmail.tar.gz 228268 2002-01-18backmail.tar.gz 226544 2002-01-19backmail.tar.gz 0 2002-01-20backmail.tar.gz After ls -1 *backmail.tar.gz | sort -r | sed -e 1,3d | xargs rm -f, it only keeps 3 days of the following: 99468 2001-11-22backmail.tar.gz 226544 2002-01-19backmail.tar.gz 228268 2002-01-18backmail.tar.gz NOT 2002-01-18backupmail.tar.gz 2002-01-19backupmail.tar.gz 2002-01-20backupmail.tar.gz --- Giorgos Keramidas wrote: > On 2002-01-16 07:53:28, ann kok wrote: > > > > 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. > > See my followup to the list :))) > > Try "sort -r" .. I was sleepy and made a typo there. > The correct command should be: > > $ ls -1 mail.* | sort -r | sed -e 1,3d > > -- > 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