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
 
LinkBack Search this Thread
Old 02-15-2011, 09:02 AM   #1
daweefolk
Member
 
Registered: Sep 2009
Distribution: debian
Posts: 70

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: C:\MSDOS\
Distribution: Scientific Linux 6
Posts: 1,217

Rep: Reputation: 287Reputation: 287Reputation: 287
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: Mint
Posts: 5,401

Rep: Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110
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
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 7,514
Blog Entries: 1

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
Hi,

cat /proc/loadavg

 
Old 02-15-2011, 09:17 AM   #5
EricTRA
Guru
 
Registered: May 2009
Location: Barcelona, Spain
Distribution: LMDE Gnome with Awesome WM + Kernel 3.3.0-1 amd64
Posts: 6,529
Blog Entries: 1

Rep: Reputation: 1220Reputation: 1220Reputation: 1220Reputation: 1220Reputation: 1220Reputation: 1220Reputation: 1220Reputation: 1220Reputation: 1220
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
Trackbacks are Off
Pingbacks are On
Refbacks are 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:19 AM.

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
Open Source Consulting | Domain Registration