1

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 backslash?

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 don't know what happened 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 it's the same the first c:\windows\Fonts, I don't know why the path are not full in the variable result.

0

2 Answers 2

3

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

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

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'  
2

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

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

Example:

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

Another way is to use tr:

tr '/' '\\'

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

$ echo $PWD | tr '/' '\\'
\home\pandya

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .