1.

Solve : unix replace character?

Answer»

hi i would like to know how to REPLACE the 2nd/3rd... character in a string without knowing what value it holds.update:i CANOT use sed or awk..
for example : if i do
$ expr index "string" N
i'll get 5, as n is the fith char, so how do i replace the 5th char?
you just do a substring

Code: [Select]$ s=1234
$ echo "${s:0:2}replace${s:3}"
12replace4
THIS IS EXACTLY WHAT I'M LOOKING FOR!!!!!! THANKS MATE!!THIS IS EXACTLY WHAT I'M LOOKING FOR!!!!!! THANKS MATE!!

*sorry..didnt see that reply THING..
Quote from: ghostdog74 on March 21, 2010, 06:50:33 AM

you just do a substring

Code: [Select]$ s=1234
$ echo "${s:0:2}replace${s:3}"
12replace4



Discussion

No Comment Found