code_junkie

DOS filename escaping for use with *nix commands

Nov 10th, 2011
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. set FILENAME=%~f1
  2.  
  3. sed 's/Some Pattern/%FILENAME%/' inputfile
  4.  
  5. set FILENAME=%~f1
  6. cygpath "s|Some Pattern|%FILENAME%|" >sedcmd.tmp
  7. sed -f sedcmd.tmp inputfile
  8. del /q sedcmd.tmp
  9.  
  10. set FILENAME=%~f1
  11. echo s/Some Pattern/%FILENAME%/ | sed -e "s/\/\\/g" >sedcmd.tmp
  12. sed -f sedcmd.tmp inputfile
  13. del /q sedcmd.tmp
  14.  
  15. > cygpath -m c:somepath
  16. c:/some/path
Add Comment
Please, Sign In to add comment