Solved

sed question

Posted on 2001-07-11
10
325 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
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…
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.

932 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

10 Experts available now in Live!

Get 1:1 Help Now