sed syntax
Jamon Camisso
jamon.camisso-H217xnMUJC0sA/PxXw9srA at public.gmane.org
Tue Feb 3 21:16:21 UTC 2009
Matt Price wrote:
>>> 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?
Try '{print $NF}'.
Even better:
awk '/I\/O error/ {print $NF}' file.txt
The part between the / / is for regexes, escaped as usual (like I\/O
instead of I/O) using a \.
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
More information about the Legacy
mailing list