`source〜/ .bash_profile`在bash脚本中不起作用

感官

这是一个脚本,它将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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

为什么 os.system("source /home/oracle/.bash_profile") 不起作用

在Docker中安装Rust工具链时,Bash`source`命令不起作用

创建.bash_profile后...终端不起作用

为什么我的〜/ .bash_profile不起作用?

从 bashrc 或 bash_profile 加载变量不起作用

.bash_profile中定义的别名在OS X中不起作用

MacOS Catalina 升级后 bash_profile 中的别名不起作用

if语句在Bash脚本中不起作用

别名在Bash脚本中不起作用

排序在 bash 脚本中不起作用

awk在bash脚本中不起作用

为什么`source / home / vagrant / .bashrc`在Vagrant Shell配置脚本中不起作用?

为什么`source`与virtualenvwrapper一起在.bash_profile中使用?

condas`source activate virtualenv`在Dockerfile中不起作用

为什么`source〜/ .aliases`在.zshrc中不起作用?

为什么导出的变量而不是.bash_profile的别名在非登录shell中起作用?

source()不起作用(“节点堆栈溢出”)

我的bash脚本中嵌套了`source`命令吗?

为什么`source foo && true`会退出bash中的脚本?

为什么bash别名在脚本中不起作用?

crontab中的Bash脚本不起作用

curl outfile变量在bash脚本中不起作用

BASH脚本中的错误退出不起作用

模式匹配在bash脚本中不起作用

为什么超时在bash脚本中不起作用?

Bash脚本命令在cron中不起作用

我的 awk 用户函数在 bash 脚本中不起作用

Docker 运行命令在 bash 脚本中不起作用

lockfile-create在bash脚本中不起作用