在环境变量波浪线扩展 [英] tilde expansion in environment variable

查看:237
本文介绍了在环境变量波浪线扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的sh文件,我都这样了, CP $文件$ SOME_PATH ,而$ SOME_PATH导出为出口SOME_PATH =〜/路径/到/路径/。但是,当我跑这sh文件,我得到错误提示说,如*没有这样的〜/路径/要/路径/的存在。*
我换成〜为$ HOME,那么错误就不见了。
那么什么用波浪线在这里了?

In my .sh file, I have this, cp $file $SOME_PATH, while $SOME_PATH is exported as 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. So what's up here with the tilde?

先谢谢了。

推荐答案

使用

SOME_PATH=~/path/to/path/

如果您的路径有空格,引号,

if you path have spaces, quote it

SOME_PATH=~/"path with spaces"

这篇关于在环境变量波浪线扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆