Re: [Nolug] sed question

From: Fritz <fgurtler_at_gmail.com>
Date: Mon, 20 Nov 2006 17:07:19 -0600
Message-ID: <e9c2c3740611201507o52d2290fy6b3a8e3df59b5a0d@mail.gmail.com>

grep "@@" data.txt | tail -1 | sed 's/@@\([0-9]*\)@@.*/\1/'

I had to bug someone to give me a shell account. Now the [0-9]* part
assumes that the data between the @@ and @@ is numeric. If you just want to
grab whatever, change it to .*

On 11/20/06, Fritz <fgurtler@gmail.com> wrote:
>
> I sadly dont have a box to test this on, but try
>
> sed -e 's/@([0-9]*)@/\1/' or something along those lines.
>
>
>
> On 11/20/06, David John < djohn@archdiocese-no.org> wrote:
> >
> > Hello List,
> >
> > I'm using GNU sed version 4.1.4.
> > Let's say I have a file.txt that contains:
> > @@1234@@ -- abcd
> >
> > All I want is whatever is between the "@@", e.g. 1234; the rest can be
> > discarded.
> >
> > If I do:
> > grep "@@" file.txt | tail -1 | sed -e 's/@@//' -e 's/@@//'
> > it returns:
> > 1234 – abcd
> >
> > What's the best way to get whatever is between the "@@", while
> > discarding the rest of the line?
> >
> > (I could have "Googled" a little harder but figured I'd use the list.)
> >
> > Thanks.
> >
> > David
> >
> > This message has been scanned by the Internet Service Departments
> > Virus/Spam filter.
> >
> >
>

___________________
Nolug mailing list
nolug@nolug.org
Received on 11/20/06

This archive was generated by hypermail 2.2.0 : 12/19/08 EST