LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 02-15-2011, 09:02 AM   #1
daweefolk
Member
 
Registered: Sep 2009
Distribution: debian
Posts: 76

Rep: Reputation: 15
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-

Last edited by daweefolk; 02-15-2011 at 09:41 AM.
 
Old 02-15-2011, 09:09 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,272
Blog Entries: 1

Rep: Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055
Quote:
Originally Posted by daweefolk View Post
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-
 
Old 02-15-2011, 09:09 AM   #3
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,562

Rep: Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939
Well the simplest version is probably:
Code:
uptime | sed s'/^.*load/load/'
 
Old 02-15-2011, 09:14 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

cat /proc/loadavg

 
Old 02-15-2011, 09:17 AM   #5
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Hi,

Or with awk, dirty but works
Code:
uptime |awk -F',  ' '{ print $3, $4, $5}'
Kind regards,

Eric
 
  


Reply

Tags
awk, cut, sed, shell


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get data from multi lined text file using awk, sed or perl - grep & cut not upto par cam34 Programming 4 07-02-2010 03:10 AM
[SOLVED] Pattern matching with sed vinaytp Linux - Newbie 3 05-24-2010 07:33 AM
Sed pattern replacement icyrail Programming 3 10-27-2009 05:33 AM
replace a text pattern with the reverse of another text pattern lothario Linux - Software 5 07-25-2008 02:43 PM
last pattern with sed? xpto09 Linux - Newbie 6 10-04-2007 08:01 PM


All times are GMT -5. The time now is 09:24 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration