如何将环境变量中的文件名传递给cygwin中的sed?

时间:2013-12-19 04:58:32

标签: bash shell cygwin

在我的Cygwin XP控制台中,我可以运行:

$ sed -i "s/font*=.*/font=TT DejaVu Sans Mono/g" "/cygdrive/c/Program Files/R/R-3.0.2/etc/Rconsole"

但是,当我设置变量时:

sanya@ligong-a691b08a ~
$ fname="/cygdrive/c/Program Files/R/R-3.0.2/etc/Rconsole"

运行时遇到错误:

sanya@ligong-a691b08a ~
$ sed -i "s/font*=.*/font=TT DejaVu Sans Mono/g"   $fname
sed:can't read /cygdrive/c/Program:No such file or directory
sed:can't read Files/R/R-3.0.2/etc/Rconsole:No such file or directory

如何修复此命令?

1 个答案:

答案 0 :(得分:0)

引用带空格的文件名:

sed -i "s/font*=.*/font=TT DejaVu Sans Mono/g" "$fname"