Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Jan 2002 12:47:23 -0800 (PST)
From:      ann kok <annkok2001@yahoo.com>
To:        Giorgos Keramidas <keramida@ceid.upatras.gr>
Cc:        questions@FreeBSD.ORG
Subject:   Re: crontab to backup mail in date format
Message-ID:  <20020121204723.40222.qmail@web20103.mail.yahoo.com>
In-Reply-To: <20020117015810.GB20298@hades.hell.gr>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <keramida@ceid.upatras.gr>
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020121204723.40222.qmail>