LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-18-2009, 08:47 AM   #1
deathalele
Member
 
Registered: May 2008
Location: deep dark north wales
Distribution: Zenwalk
Posts: 162

Rep: Reputation: 30
Using sed to change everything apart from one string


Say i have a line full of completely pointless stuff but useful information enclosed within some string
Quote:
nhdjasklfhduhsifhdklhdflghldhbulhl startimportantend bhfydsgbsd
can i do something like
Quote:
sed './everything apart from 'start.........end'//'
hope this is clear enough
Thanks in advance
 
Old 03-18-2009, 08:57 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Code:
echo "dhbulhl startimportantend bhfyd" | sed -n 's/^.*start\(.*\)end.*$/\1/p'
 
Old 03-22-2009, 12:55 PM   #3
deathalele
Member
 
Registered: May 2008
Location: deep dark north wales
Distribution: Zenwalk
Posts: 162

Original Poster
Rep: Reputation: 30
Thanks.
exactly what i needed
 
  


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
Trying to change String using sed with a string \/home\/user\/Desktop icecoolcorey Programming 10 06-12-2008 11:32 PM
sed replace string octeto Programming 4 06-06-2007 02:09 AM
How can I replace this string with another using sed? dave4545 Programming 7 01-27-2006 10:58 AM
insert string with sed greg108 Programming 7 02-18-2005 01:11 PM
[sed] replace string? chuanyung Programming 3 03-11-2004 08:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:30 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