LinuxQuestions.org
Visit the LQ Articles and Editorials 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-18-2006, 07:30 AM   #1
Hivemind
Member
 
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, 08:13 AM   #2
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,393
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
miguel@gold:~>

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


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


All times are GMT -5. The time now is 11:29 PM.

Main Menu
Advertisement
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