检查~/.bash_profile节目内容:
codio@data-burma:~$ cat ~/.bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
cd /home/codio/workspace
codio@data-burma:~$
Run Code Online (Sandbox Code Playgroud)
所有这些代码.bash_profile是什么意思?
下面的答案基于.bash_profile中对.bashrc中由乔什斯泰格。有关详细信息,请查看该页面的内容。
根据 bash 手册页,
.bash_profile为登录 shell.bashrc执行,而为交互式非登录 shell 执行。
大多数情况下,您不想为登录和非登录 shell 维护两个单独的配置文件——当您设置 a 时
PATH,您希望它适用于两者。您可以通过.bashrc从.bash_profile文件中获取资源来解决此问题,然后将 PATH 和通用设置放在 .bashrc 中。为此,请将以下几行添加到
.bash_profile:Run Code Online (Sandbox Code Playgroud)if [ -f ~/.bashrc ]; then source ~/.bashrc fi
上面的代码执行以下操作:
~/.bashrc存在。source它(“执行它”)。