这是一个将 bash 文件移动到主页并使用 source 命令加载它的脚本。
# update.sh
#!/bin/bash
cp -f $PWD/bash_profile ~/.bash_profile
source ~/.bash_profile
Run Code Online (Sandbox Code Playgroud)
这是行不通的!它用cp -f $PWD/bash_profile ~/.bash_profile.
里面~/.bash_profile有一个新的 PS1 定义。文件已更新,但在打开新窗口之前未发生任何更改。我需要跑source ~/.bash_profile在脚本执行后...
是否可以source在 bash 脚本中运行命令?