Re: Help with String Extraction - Variation



On Wed, 26 Sep 2007 10:53:12 +0000, Vishal Sharma wrote:

[snip]

Why i need to only extract from the "load average" string, is because
everytime the output of command uptime might vary. sometimes the time is
shown like this

server0 up 6 days 42 mins load average: 0.01 0.02 0.03

so in such a case your suggestion might not work. So the easiest would
be to search for the word "load" and extract everything after that.

Pls provide me some solution.

Thanks,

So you have a clear requirement, just write it....

sed 's/^.*load/load/'

or in english, the sed "program s/^.*load/load, protected by "'"
characters so the shell leaves it alone
s substitue
/ use / as the pattern delimiter
^ start of line
.. any character
* repeated any number of times, including zero
load followed by "l", "o", "a", and "d" in that order
/ end of first pattern, start of second pattern
load the characters "l", "o", "a", and "d"
/ end of second pattern
.



Relevant Pages