sed command doubt
Hi ,
I want to replace "hello test" with "Hello this is test" in a file called "TODAYSTST".But there are many other lines in the same file which is having "hello test".But I would like to replace only the first occurence"hello test" using sed. Please could anyone help me in this using sed command options. |
Well, from some searching and experimentation, this seems to work:
Code:
sed '0,/hello test/s//Hello this is test/' TODAYSTST |
Many thanks :)
|
Code:
sed '0,/hello test/s//Hello this is test/' TODAYSTST Code:
sed '0,/.*hello test/s/hello test/Hello this is test/' TODAYSTST s/hello test/Hello this is test/ substitute then in that Linegroup the text "hello test" with "Hello this is test" one time. |
First command worked for me.But thank you for the detailed explanation.
|
Quote:
Using the file Quote:
|
Quote:
|
Quote:
when the arguement you are searching for is the same as the argument you want to replace you can omit the second instance of it. |
All times are GMT -5. The time now is 07:46 PM. |