LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-19-2012, 07:18 AM   #16
krazyglue
Member
 
Registered: Oct 2003
Posts: 68

Original Poster
Rep: Reputation: 16

Pix,

Thanks for the break down, it helped immensely. Apparently sed is MUCH more complex than originally thought. Along with that, much more powerful as well. Thanks for the help guys!



Pan care to break yours down as well?
 
Old 06-19-2012, 07:39 AM   #17
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
sed -n '/^Disk/ {s! /.*:!!; s!,.*$!!;p }' sourcefile
Code:
-n     turn off any output unless specified

/^Disk/     for all lines beginning with "Disk", do the following statments (grouped using {})

s! /.*:!!     delete one instance of: space, followed by / then any number of characters and then a :

s!,.*$!!     at the end of the line,  delete:  comma, followed by any numuber of characters

p       after all the above, print what's left
Note the use of "!" as the delimiter---this allows the literal "/" to be used inside. In the sed "s" command, the first character after the s is the delimiter.
 
  


Reply



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
[SOLVED] sed help to run sed command against multiple different file names bkone Programming 2 04-16-2012 12:27 PM
sed and regexp matching (GNU sed version 4.2.1) Ashkhan Programming 8 02-27-2012 09:12 AM
[SOLVED] head -n -1 (sed -n -e '1,$-1p' is incorrect) sed question, as stupid as it could be. kaz2100 Programming 1 12-27-2011 09:18 PM
[SOLVED] sed 's/Tb05.5K5.100/Tb229/' alone but doesn't work in sed file w/ other expressions Radha.jg Programming 6 03-03-2011 07:59 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:18 PM.

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