Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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-18-2006, 06:30 AM   #1
Registered: Sep 2004
Posts: 273

Rep: Reputation: 30
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
Old 01-18-2006, 07:13 AM   #2
Senior Member
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,402
Blog Entries: 1

Rep: Reputation: 64
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

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


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
SED - remove last four characters from string 3saul Linux - Software 9 12-14-2015 04:43 PM
using sed to remove word wrap Harpune Linux - Software 2 03-02-2009 06:53 PM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM
Using sed in bash to remove whitespace jimieee Programming 3 01-28-2004 10:33 AM
sed: replace one line with >one line bbeers Programming 3 11-19-2002 05:27 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:49 AM.

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