LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 01-09-2006, 08:00 PM   #1
3saul
Member
 
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, 09:11 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
I think awk would be prettier in this case.
Code:
sed 's/\([[:alpha:]]*\) \([[:alpha:]]*\) \([[:alpha:]]*\) .*/\3/' file.txt
Code:
awk '{print$3}' file.txt
 
Old 01-28-2007, 12:06 PM   #3
yitzle
Member
 
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?
 
  


Reply


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


All times are GMT -5. The time now is 12:15 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 Google+: linuxquestions
Open Source Consulting | Domain Registration