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