I'm trying to write a script to import a font in wine, because I put the font in wine's c:\Windows\Fonts, but wine doesn't read it if I don't import from the reg file:

"Font Name"="Z:\path\to\my\wineprefix\c:\Windows\Fonts\file.ttf"

And I don't know how to change the "/" to "\", using "$(pwd)" or $PWD. Does someone know how I can replace the slash with a back slash?

I have a trouble with echo and with the output file . in my bash script i have this

RUTA=""$( cd -P "$( dirname "$" )" && pwd )""
RUTAINVERSA=$(printf '%s\n' "${PWD//\//\\}")

well i has try with the follows :

1 :

echo 'REGEDIT4

[HKEY_CURRENT_USER\\Software\\Wine\\Fonts\\External Fonts]
"Courier New"="'"Z:\\$RUTAINVERSA\\wine\\data\\dosdevices\\c:\\windows\\Fonts\\cour.ttf"'"
"Courier New Bold"="'"Z:\\$RUTAINVERSA\\wine\\data\\dosdevices\\c:\\windows\\Fonts\\courbd.ttf"'"' >> "$ARREGLOS/Fuentes.reg"

The result in the past are : c:\Windows\Fonts , and i dont know what happend with the rest with \file.ttf

2 :

echo >> "$ARREGLOS/Fuentes.reg"
echo "[HKEY_CURRENT_USER\\Software\\Wine\\Fonts\\External Fonts]" >> "$ARREGLOS/Fuentes.reg"
echo "Courier New"="c:\\windows\\Fonts\\cour.ttf" >> "$ARREGLOS/Fuentes.reg"
echo "Courier New Bold"="c:\\windows\\Fonts\\courbd.ttf" >> "$ARREGLOS/Fuentes.reg" 

The result are : Courier New c:windowsFontcour.tff Courier New Bold c:widowsFontscourbd.ttf

3 :

[HKEY_CURRENT_USER\\Software\\Wine\\Fonts\\External Fonts]
"Courier New"="'"c:\\\windows\\\Fonts\\\cour.ttf"'"
"Courier New Bold"="'"c:\\\windows\\\Fonts\\\courbd.ttf"'" ' >> "$ARREGLOS/Fuentes.reg"

and its the same the first c:\windows\Fonts , i dont know why the path are not full in the varible result

i solve the 3: with

[HKEY_CURRENT_USER\\Software\\Wine\\Fonts\\External Fonts]
"'"Courier New"'"="'"c:\\\\\\\\windows\\\\\\\\Fonts\\\\\\\\cour.ttf"'"
"'"Courier New Bold"'"="'"c:\\\\\\\\windows\\\\\\\\Fonts\\\\\\\\courbd.ttf"'"'  >> "$ARREGLOS/Fuentes.reg"

I'm not entirely sure what you're trying to do but changing the slashes is easy:

$ printf '%s\n' "${PWD//\//\\}"

This is using ksh's string manipulation capabilities also available in bash. Specifically, ${foo//bar/baz/} will replace all occurrences of the string bar with baz in the variable $foo. Since / and \ are special characters, they need to be escaped (\\ and \/) for this to work with them. The above is equivalent to:

pwd | sed 's#/#\\#g'  
|improve this answer|||||

You can use sed to convert all / into \ by following command:

sed  's/\//\\/g'


$ echo $PWD | sed  's/\//\\/g'

Another way is to use tr:

tr '/' '\\'

By above command, tr convertes all / with\; Example:

$ echo $PWD | tr '/' '\\'
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.