Read file and replace a particular line if found

Hi All
There is another challenge which stand in front of me. And want all to have the experience with that

I have a file in Unix say a.txt. What I was trying is to read the file line by line and matching the line to particular pattern, and if that pattern found I want to replace that line with that particular pattern.

I know there are several ways to do, but I want to do it in that way only due to some large process constraints

Regards
Adi

is your search pattern and replace pattern remain same?

I mean say you have "Hello World I am..." search pattern is Hello now if found you want that line to be replaced by just Hello? or something else?

Please clarify

Sorry I miss that.
Suppose my file contain data is as follow

Hello I am great
My best website is Unix.com
Hello my name is adisky
Code tag button

and my search pattern will be the one of the line from file only

Code tag button

and if the pattern found it should replace with

Code tag button;Code tag button

Regards
ADI

simple and straight fwd would be

 
sed 's/Code tag button/&;&/g'  filename

and suppose If my line in a files is

A;B;C;D;E;F;

and my search pattern is

 A;B;C;D;E;F;

and if found it should replace it like

A;B;C;D;E;F;G;H;I;J;K

hmmm it would be easy if you can provide exact file :slight_smile:

 
sed 's/A;B;C;D;E;F;/&G;H;I;J;K/g' filename