这是一个脚本,它将bash文件移动到主页中并使用source命令加载它。
# update.sh
#!/bin/bash
cp -f $PWD/bash_profile ~/.bash_profile
source ~/.bash_profile
这没用!它使用来更新文件cp -f $PWD/bash_profile ~/.bash_profile
。
里面~/.bash_profile
有一个新的PS1定义。文件已更新,但是直到打开新窗口后才发生更改。我需要source ~/.bash_profile
在脚本执行后运行...
是否可以source
在bash脚本中运行命令?
从MangeshBiradar在这里:
使用. ./
(点空格点斜杠)执行Shell脚本
如下所示,在使用“点空格点斜杠”执行shell脚本时,它将在当前shell中执行脚本,而不会派生子shell。
$ . ./setup.bash
换句话说,这将在当前shell中执行setup.bash中指定的命令,并为您准备环境。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句