Tuesday, October 31, 2006
Find and Replace in VI
I am trying to change all occurances of /a1/a2 with /a1/b1 in a file. How to do it
1. in vi editor?
2. from command prompt?
Ans :
:1,$ s/\/a1\/a2/\/a1\/b1/g
I am trying to change all occurances of xxx with yyy in a file. How to do it
1. in vi editor?
2. from command prompt?
Ans :
:1,$ s/xxx/yyy/g OR :%s/xxx/yyy/g
OR with out opening the VI Editor you can try sed 's/xxx/yyy/g' filename > filename2
1. in vi editor?
2. from command prompt?
Ans :
:1,$ s/\/a1\/a2/\/a1\/b1/g
I am trying to change all occurances of xxx with yyy in a file. How to do it
1. in vi editor?
2. from command prompt?
Ans :
:1,$ s/xxx/yyy/g OR :%s/xxx/yyy/g
OR with out opening the VI Editor you can try sed 's/xxx/yyy/g' filename > filename2