problem in replacing string in vi editor
I tried to replace a windows directory structure to linux directory structure in vi editor but it's giving me error "E488 trailing characters" (O.S is redhat 5)
F:\oracle\app\oradata I want to replace it to /u002/app/oracle I have been searching this for 2 days & didn't get any solution.! Can any body know how to replace it? Thanks in advance......! |
Hi,
The back slashes in the original path are special and so are the forward slashes in the replace part. Try this: Code:
:s%F:\\oracle\\app\\oradata%/u002/app/oracle% |
Hello texasj,
for me with vim this works Code:
:%s/F:\\oracle\\app\\oradata/\/u002\/app\/oracle/g % search the whole file s substitute \\ a backslash \/ a slash in Linux/Unix g replace every occurence in the whole line (without g it replaces only the first one) Markus |
Hi markush,
Quote:
1) You have a double backslash before the F: 2) The back-referencing doesn't replace the backslash between app and oradata (it should also be replaced by something else). EDIT: The above code has been changed (see post #5). |
Quote:
Markus |
@markush: :)
The OP now has 2 ways of solving his/her problem! |
Hello druuna,
Quote:
Markus |
Thanks a bundle DRUUNA & MARKUSH i able to solve the problem with your solutions, sorry for the late reply ! both of you certainly made my day as i was totally frustrated due to this problem!
Thaaaaaaaaanks a bunnnnnndle...! Here how you solved this problem: 1. First solution [druuna] :s%F:\\oracle\\app\\oradata%/u002/app/oracle% -->This solution is good when replacing only one line. #by mistake I didn't mentioned that there are more than one lines to be replaced. 2. Second solution [markus] :%s/F:\\oracle\\app\\oradata/\/u002\/app\/oracle/g -->Replaces all the lines in the file Thanks again for educating me...!;) |
You're welcome :)
|
All times are GMT -5. The time now is 09:37 AM. |