前端之家收集整理的这篇文章主要介绍了
linux – 无法在当前目录中获取脚本,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
显然,如果脚本在当前目录中,我无法
获取脚本.例如,
# source some/dir/script.sh
Ok
工作正常,但如果我和脚本在同一个目录中,则会出错:
# cd some/dir
# source script.sh
-sh: source: script.sh: file not found
是什么赋予了?这是改变目录的唯一方法吗?
如果相关,我在Angstrom Linux上使用bash v4.2.10.
引用源手册页:
source filename [arguments]
….
If filename does not contain a slash,file
names in PATH are used to find the directory containing file-
name.
所以……源代码试图在PATH中包含的文件夹中搜索你的script.sh.
如果要在当前文件夹中使用源文件
source ./script.sh
原文链接:https://www.f2er.com/linux/395102.html