In GNU sed (and almost all other distributions I know of):
SET VAR=C:\nyc
sed "s/PATH/%VAR%/g" file.txt
causes any occurrence of PATH to be replaced with a new line followed by "yc". In my case VAR is always a user supplied literal (it's a Windows path). How can I disable the default interpreting of '\\'? (I know about hacks like saving VAR in a file and replacing all "\\" with "\\\\" in VAR and then passing it to sed)
you can modify %var%
in the Windows command shell:
>type file PATH PATH >set var=C:\nyc >sed "s/PATH/%VAR%/g" file C: yc C: yc >set var=%var:\=\\% >echo %var% C:\\nyc >sed "s/PATH/%VAR%/g" file C:\nyc C:\nyc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.