thanks a lot for the reply!!
i want this to add only for "hello".. how to do that...? not generic..!! can anybody please help me to understand the above code too??
---------- Post updated at 10:46 PM ---------- Previous update was at 06:47 AM ----------
myfile
hru:122:
hello:123:john,philip,mary,kp,moss
hi:124:
bye:125:
hi:124:
bye:125:
hi:124:
bye:125:
tata:125:pipe,grep
How to modify the above script just to add the new value only to "hello" not for tata. Script should be some what like, search for hello and add the new value there. Each new values to be separated by a comma.. Sorry for not being so clear in my first post
So if the new value i have is foo, the modified file should be like this..
hru:122:
hello:123:john,philip,mary,kp,moss,foo
hi:124:
bye:125:
hi:124:
bye:125:
hi:124:
bye:125:
tata:125:pipe,grep
I modified the script like this..
awk -v val='foo' '!/:$/ {$0=$0 "," val}1' myfile > myfilenew
cat myfilenew > myfile
rm -rf myfilenew
bu the output im getting is like the following...
the new myfile
hru:122:
hello:123:john,philip,mary,kp,moss,foo
hi:124:
bye:125:
hi:124:
bye:125:
hi:124:
bye:125:
tata:125:pipe,grep,foo
It would be a great help if some one can help me in this.