Solved

sed question

Posted on 2001-07-11
10
330 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
Technology Partners: 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!

 
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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Linux :how to provide sudo access to the user 13 130
Correct syntax to upload file in a script using sftp 2 109
Sed question 2 139
check the file dates in unix 14 77
When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
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…
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.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

738 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