Search and Insert

Hi All
I got one problem and want your help,what i want to do is

Input

123     key0=A;B;C;:key1=X;Y;Z;:

here 123 is a username
I should search the username (in this case it is 123) in file and if found it should insert the additional string D as below
Here 123 and key are tab seperated

Output

123     key0=A;B;C;D;:key1=X;Y;Z;D;:

Based on your example, would a blunt "sed" do?
The white space is typed as a real "tab" character.

sed -e 's/^123  key0=A;B;C;:key1=X;Y;Z;:/123    key0=A;B;C;D;:key1=X;Y;Z;D;:/g'

@methy
I didn't get you

---------- Post updated at 09:41 AM ---------- Previous update was at 09:16 AM ----------

in output i am getting the input only...

sed '/^123/{s/;:/;D:/g}'  infile

--ahamed

Is it possible that it should search the pattern in a file and if the pattern is found it should update the file itself

@partmittal2007
Check whether your version of "sed" has the "-i" switch.

Yes its there