sed syntax
Matt Price
matt.price-H217xnMUJC0sA/PxXw9srA at public.gmane.org
Tue Feb 3 20:18:53 UTC 2009
On Tue, 2009-02-03 at 14:29 -0500, Jamon Camisso wrote:
> Lennart Sorensen wrote:
> > On Tue, Feb 03, 2009 at 11:20:44AM -0500, Matt Price wrote:
> >> after all these years with linux i still have all kinds of trouble with
> >> regexp's. i have a file full of error messages from dmesg:
> >>
> >> [125559.165041] Buffer I/O error on device sda5, logical block 19698429
> >>
> >> (i know, it's not a good sign; i'm just trying to hang onto this drive
> >> for a little longer)
> >>
> >> i want to cut these lines back so i just have the block number:
> >> 19698429\
> >> cat file | sed 's/(^.*)([0-9]*$)/\2/'
> >>
> >> but that returns the initial file unmodified.
> >>
> >> any ints out there? thanks as always,
^hints
> >
> > How about:
> >
> > sed 's/.*block \([0-9]*\)$/\1/'
> >
hmm, that also seems to just return the same data unprocessed.
>
> > I think the main problem was you failed to escape the ()'s which sed
> > requires.
> >
>
> Sed works, but awk is designed for just the task you're attempting:
> cat file.txt | awk '{print $10}'
>
cool. what if there weren't always 10 fields? is there a
straightforward awk way to just get the final numerical expression?
thx again,
m
> Jamon
> --
> The Toronto Linux Users Group. Meetings: http://gtalug.org/
> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
--
Matt Price
matt.price-H217xnMUJC0sA/PxXw9srA at public.gmane.org
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list