Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

sed question

Posted on 2001-07-11
10
Medium Priority
?
335 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 51

Accepted Solution

by:
ahoffmann earned 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

715 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