LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Another SED question (https://www.linuxquestions.org/questions/linux-software-2/another-sed-question-401391/)

3saul 01-09-2006 08:00 PM

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?

homey 01-09-2006 09:11 PM

I think awk would be prettier in this case.
Code:

sed 's/\([[:alpha:]]*\) \([[:alpha:]]*\) \([[:alpha:]]*\) .*/\3/' file.txt
Code:

awk '{print$3}' file.txt

yitzle 01-28-2007 12:06 PM

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?


All times are GMT -5. The time now is 03:04 AM.