Solved

sed question

Posted on 2001-07-11
10
324 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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…
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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now