I want to avoid the DOS file name, so I can use it with sed. I have a DOS batch file something like this:
set FILENAME=%~f1
sed 's/Some Pattern/%FILENAME%/' inputfile
(Note: %~f1- extends %1to the full path name - C:\utils\MyFile.txt)
I found that the backslash in %FILENAME%just eludes the next letter.
How can I double them so that they are shielded?
(I have cygwin installed, so feel free to use any other * nix commands)
Decision
Combining the suggestions of Jeremy and Alexandra Week and using | for the separator in the sed command I have
set FILENAME=%~f1
cygpath "s|Some Pattern|%FILENAME%|" >sedcmd.tmp
sed -f sedcmd.tmp inputfile
del /q sedcmd.tmp
source
share