3
可以为以下命令临时设置PATH。另外,PATH可以在脚本中设置,该脚本永久保存(在该终端或会话中)。如何在脚本中设置全局有效的PATH,而不是脚本完成后?如何只在bash脚本中临时设置PATH?
例子:
PATH=$PATH:/path1 path1 is valid only for this line
export PATH=$PATH:/path2
path2 is valid for this line
and this line too
I like it
exit
> path2 is still valid after the script finishes
> and when I type commands here manually
> I don't like it
呃......看来我完全错了......但是为什么在'.bashrc永久导出'? (对不起,这可能是另一个问题) – akai
@akai'.bashrc'文件来自与启动的shell相同的环境。这不是一个在自己的环境中运行的脚本。 – Kusalananda