LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how can i use sed to cut out all the text up until the pattern? (http://www.linuxquestions.org/questions/linux-newbie-8/how-can-i-use-sed-to-cut-out-all-the-text-up-until-the-pattern-862833/)

daweefolk 02-15-2011 09:02 AM

how can i use sed to cut out all the text up until the pattern?
 
I want to cut out part of the 'uptime' output so all it displays is the load average. In the end I want to cut out everything before the word 'load'. I am a total sed newbie and could really use some examples or links. I've googled and haven't found anything useful yet.

##edit###
I used the 'cut' command- The code was
Code:

uptime |cut -d, -f 2,3,4,5 |cut 13-

szboardstretcher 02-15-2011 09:09 AM

Quote:

Originally Posted by daweefolk (Post 4259152)
I want to cut out part of the 'uptime' output so all it displays is the load average. In the end I want to cut out everything before the word 'load'. I am a total sed newbie and could really use some examples or links. I've googled and haven't found anything useful yet.

You could use cut..

Code:

uptime|cut -b33-

grail 02-15-2011 09:09 AM

Well the simplest version is probably:
Code:

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

druuna 02-15-2011 09:14 AM

Hi,

cat /proc/loadavg

;)

EricTRA 02-15-2011 09:17 AM

Hi,

Or with awk, dirty but works :)
Code:

uptime |awk -F',  ' '{ print $3, $4, $5}'
Kind regards,

Eric


All times are GMT -5. The time now is 02:06 AM.