Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 01-09-2006, 09:00 PM   #1
Registered: Aug 2004
Location: Brisbane, Australia
Distribution: Ubuntu/Fedora
Posts: 86

Rep: Reputation: 15
Another SED question

I'm wanting SED to return the third word from a line of text and delete everything else. Can this be done?
Old 01-09-2006, 10:11 PM   #2
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 58
I think awk would be prettier in this case.
sed 's/\([[:alpha:]]*\) \([[:alpha:]]*\) \([[:alpha:]]*\) .*/\3/' file.txt
awk '{print$3}' file.txt
Old 01-28-2007, 01:06 PM   #3
Registered: Aug 2006
Posts: 50

Rep: Reputation: 15
Didn't want to bother making *another* sed thread, so...
How do I go about exracting a section of text
I basically want: sed 's/^.*(BEGIN.*END).*$/\1/'
Is there a shorter way to write this?


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
question on sed tifu Linux - Newbie 3 03-18-2005 05:38 PM
sed question lazyuser Programming 4 02-11-2005 07:11 AM
sed question virendratp Programming 3 09-10-2004 04:21 AM
sed question sphynx Programming 6 04-28-2004 07:25 PM
sed question 360 Programming 2 03-15-2002 10:52 AM

All times are GMT -5. The time now is 07:47 PM.

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