LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-30-2012, 09:42 AM   #1
surferboy
LQ Newbie
 
Registered: Oct 2012
Posts: 4

Rep: Reputation: Disabled
Remove all text before and after


I want to sed....

lots of text <test1@test1.com> -> <test2@test2.com> more unwanted text

...so that the output is...

<test1@test1.com> -> <test2@test2.com>

How do I do that?
 
Old 10-30-2012, 09:55 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Is it all on one line?

On one line:
To discard everything before and after a specific pattern, do this:
suppose you have "teddy's daddy toted two dead toads to detroit", and you want to KEEP the pattern "two dead toads":

Code:
echo "teddy's daddy toted two dead toads to detroit" | sed -r 's/.*(two dead toads).*/\1/'
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove lines in a text file based on another text file asiandude Programming 10 01-29-2009 10:59 AM
Remove text from a file jviola Programming 23 03-21-2007 12:23 PM
help with sed to remove all text except for some Benanzo Linux - Software 7 01-04-2007 06:21 AM
remove \r and \n from a text file powah Programming 9 10-02-2006 06:02 AM
remove text with grep craigdolson Linux - General 6 04-21-2004 03:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:28 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
Open Source Consulting | Domain Registration