linux - ./a.sh 和 ./a.sh 有什么区别? 。/灰?

标签 linux bash

<分区>

我所知道的是,当我有两个脚本文件时,可以说 a.shb.sh 并使用脚本 中定义的变量或函数a.sh,然后是 。 ./a.sh 有效,但 ./a.sh 无效。在运行 shell 脚本时 ./script.sh。 ./script.sh 工作正常。使用 ./script.sh 运行脚本有什么区别。 ./script.sh?

最佳答案

。 path/to/script 源文件(在同一个 shell 中执行它)。另一个调用派生了一个执行脚本的新 shell 进程。

在子进程中调用脚本将使其变量对父进程不可用。采购脚本将在同一父进程中引入和更改变量。

关于linux - ./a.sh 和 ./a.sh 有什么区别? 。/灰?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19517611/

相关文章:

linux - 解释来自/proc/[id]/mountstats 或/proc/self/mountstats 的数据

linux - 有什么办法可以只更改 linux 中的特定目录颜色?

linux - 使用 Bash 循环遍历 txt 文件中的唯一行

Linux远程启动/停止过程

linux - 查找目录和子目录中的所有零字节文件

linux - curl chunky 解析器错误

python - glance 将 Openstack 中的 Images 存储在哪里

php - 使用 .htaccess 强制将 xxx.php URL 转发到 xxx

bash 3.2.57 (macOS) 中的字符串连接

linux - Bash 脚本阻止所有 Apple 设备