[英]tilde expansion in environment variable
In my .sh file, I have this, cp $file $SOME_PATH
, while $SOME_PATH is exported as export SOME_PATH="~/path/to/path/"
. 在我的.sh文件中,我有cp $file $SOME_PATH
,而$ SOME_PATH导出为export SOME_PATH="~/path/to/path/"
。 But when I ran this .sh file, I got error message saying like * no such "~/path/to/path/" exists.* I replaced ~ as $HOME, then the error was gone. 但是,当我运行此.sh文件时,出现了错误消息,例如*不存在这样的“〜/ path / to / path /”。*我将〜替换为$ HOME,然后错误消失了。 So what's up here with the tilde? 那么代字号在这儿呢?
Thanks in advance. 提前致谢。
use 采用
SOME_PATH=~/path/to/path/
if you path have spaces, quote it 如果路径中有空格,请引用它
SOME_PATH=~/"path with spaces"
删除导出上的引号:
export SOME_PATH=~/path/to/path/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.