linux - Replacing string having forward slash in sed -
i wish replace
x.y.z.zz=/a/b/c/d/
with
x.y.z.zz=/a/b/e/d/
i know x.y.z.zz
in advance.i know line number in advance. have tried
sed "11s/.*/x.y.z.zz=\/a\/b\/e\/d\/" filename
but giving error. there better way directly search , replace string ?
sed
replaces using sed 's/pattern/replacement/'
syntax. in case, missing last /
. saying work:
sed '11s/.*/x.y.z.zz=\/a\/b\/e\/d\//' file ^
however, may cleaner use delimiter, syntax more clear. #
? (it can ~
, _
, etc.):
sed '11s#.*#x.y.z.zz=/a/b/e/d/#' file
test
$ cat a x.y.z.zz=/a/b/c/d/ b c
let's replace line 2:
$ sed '2s#.*#x.y.z.zz=/a/b/e/d/#' a x.y.z.zz=/a/b/e/d/ b c
Comments
Post a Comment