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