Solved

sed question

Posted on 2001-07-11
10
328 Views
Last Modified: 2010-04-21
Hi,

how can I tell sed to substitute the SHORTEST matching string and not the longest?

Example:
echo "<BR>Hello</FONT>test" | sed "s/.*>//;"

--> "test" is the output but I just wanted the string until the first ">" be replaced.

Thanks
0
Comment
Question by:hitzeu
  • 4
  • 2
  • 2
  • +2
10 Comments
 
LVL 6

Expert Comment

by:bira
ID: 6273090
echo "<BR>Hello</FONT>test" |rev| sed "s/.*>//;"|rev
0
 
LVL 84

Expert Comment

by:ozo
ID: 6273095
echo "<BR>Hello</FONT>test" | sed "s/[^>]*>//;"
0
 

Author Comment

by:hitzeu
ID: 6273256
Works, thanks.
And what if I wanted to filter out all TAGS inside a string ?

echo "<TAG1>text text text <TAG2> text_end" | sed .... ?
---> "text text text   text_end"
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 51

Accepted Solution

by:
ahoffmann earned 50 total points
ID: 6273504
echo "<TAG1>text text text <TAG2> text_end" | sed -e 's/<[^>]*>//g'
0
 

Author Comment

by:hitzeu
ID: 6280060
can't thank you enough....
0
 
LVL 3

Expert Comment

by:mrn060900
ID: 6288775
what about the points for ahoffmann?
0
 

Author Comment

by:hitzeu
ID: 6288787
good question..... he does not post answers, "just" comments.

Ahoffmann, how can I reward you :-)
0
 
LVL 3

Expert Comment

by:mrn060900
ID: 6288799
just accept his comment as the answer.
0
 

Author Comment

by:hitzeu
ID: 6288805
oops
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6290209
no more comments neede. Points arrived ;-)
Thanks.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question