Help Me: Trouble in Replacing "\" with "\\"
Hi All,
I am reading a file paths from a txt file and opening the files using perl. I want to replace the path "\" in Ex: d:\work\data.txt to d:\\work\\data.txt as I am not able to open the file when the path is given with single slash. Thanks, Hari. |
You can do this in SED. Perhaps the issue is that the backslash (\) is typically the escape character and so it has to be "escaped" in typical regular expressions.
This will replace a single \ with \\: Code:
sed 's/\\/\\\\/g' filename > newfilename |
Thks it worked perfect.
|
Remember to mark as SOLVED when solution has worked.
|
Quote:
|
All times are GMT -5. The time now is 07:31 PM. |