Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.bashrc未在Unix中保存_Bash_Unix - Fatal编程技术网

.bashrc未在Unix中保存

.bashrc未在Unix中保存,bash,unix,Bash,Unix,在我的~/.bashrc文件中,我定义了一个函数: function today { echo "Today's date is:" date +"%A, %B %-d, %Y" } 但是每次我启动机器,如果我启动了 $ today 我得到: -bash: today: command not found 然后我必须在每个终端选项卡上添加$source.bashrc,以便激活此功能并返回: Today's date is: Thursday, November 2, 201

在我的~/.bashrc文件中,我定义了一个函数:

function today {
    echo "Today's date is:"
    date +"%A, %B %-d, %Y"
}
但是每次我启动机器,如果我启动了

$ today
我得到:

-bash: today: command not found
然后我必须在每个终端选项卡上添加$source.bashrc,以便激活此功能并返回:

Today's date is:
Thursday, November 2, 2017 
为什么每次我重新启动机器时.bashrc都会忘记它的内容

编辑 我有

if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi
在我的~/.profile中声明。

阅读

您的shell将作为交互式登录shell启动。在这种情况下,bash读取~/.bash_配置文件或~/.bash_登录名或~/.profile,以最先找到的为准。它不会自动读取~/.bashrc

您应该将其添加到您的配置文件中:

if [[ -f ~/.bashrc ]]; then
    . ~/.bashrc
fi

您确定您的shell是bash吗-我在我的~/.profile上已经有了这个条件声明。我应该把这个也添加到~/.bashrc吗?你有~/.bash_配置文件吗?如果两者都存在,Bash将首先使用它。好吧,它可以工作,但前提是我将~/.profile内容移动到~/.Bash_profile中。我不明白为什么我不能使用~/.profiles也许你有一个~/.bash\u登录名。阅读我链接的文档并检查您的点文件。