LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   sed question: remove decoration from each line (https://www.linuxquestions.org/questions/linux-software-2/sed-question-remove-decoration-from-each-line-404868/)

Hivemind 01-18-2006 06:30 AM

sed question: remove decoration from each line
 
Hi, how can I with sed take a text file and remove everything after (and including) the @-sign if it can be found?
Say I have this file:
line one
line two@3
line three@332

I want it to look like.
line one
line two
line three

marozsas 01-18-2006 07:13 AM

miguel@gold:~> cat /tmp/z | sed -e 's/@.*//'
line one
line two
line three
miguel@gold:~> cat /tmp/z | cut -d@ -f 1
line one
line two
line three
miguel@gold:~> cat /tmp/z | awk -F@ '{print $1}'
line one
line two
line three
miguel@gold:~>

I think the cut version is more efficient than others....


All times are GMT -5. The time now is 05:28 PM.