Find and Replace

i am having a file test1.txt and its contents is as follows.
<abcaaa bbb ccc ddd>
<dddeeeffff>
<my computer>
<abcmydocuments>

Now I need to find the text abc and should be replaced as follows.
<abc>
<dddeeeffff>
<my computer>
<abc>

First line has the text "abc" and it has to be replaced with abc removing all others characters.
Second line does not have the pattern abc and so it will not be disburbed and so as the third line.
The fourth line has the text "abc" and should be replaced by abc alone ignoring all other characters.

can anyone help me out how to perform this in unix shell script.

Thanks in advance.

Krishnakanth Manivannan
Software Engineer

So what if abc is in the middle of a string...as now you are replacing all characters to the right of it but what about those to its left.

Will this do it for you?

sed 's/abc.*/abc/' File

let me guess:

sed 's/<abc.*/<abc>/' infile

<abc>
<dddeeeffff>
<my computer>
<abc>