每当我打开终端时,我得到'bash: export:`/home/shameen:/usr/bin:/usr/local/bin': 不是一个有效的标识符' 。

1 人不认可

即使在重新启动后,只要我在顶部打开终端,我就会得到这个结果

bash: export: `/home/shameen:/usr/bin:/usr/local/bin': not a valid identifier
bash: ./bashrc: No such file or directory

有什么办法能让我消除这个错误吗? 在此输入图片描述

2 个评论
你好,欢迎来到SO。请不要用图片来显示纯文本信息。只需复制-粘贴它们并将其格式化为代码块。你的主目录中是否有一个 .bashrc (不是 ./bashrc )文件?如果有,它可能是你问题的原因。打开它,寻找一个 export 命令。也搜索一下 ./bashrc 字符串。也可以看看 .profile .bash_profile ,仍然在你的主目录中,它们是其他 bash 的配置文件。
为了快速找到罪魁祸首,你也可以暂时重命名这些文件。 mkdir -p ~/tmp ,在你的主页上创建一个 tmp 的子目录。然后。 mv ~/.bashrc ~/tmp 并打开一个新的终端。如果错误仍然存在,那就不是这个了;恢复。替换代码3】,然后用列表中的下一个试试。
linux
bash
terminal
directory
export
shameen anwar
shameen anwar
发布于 2021-08-17
1 个回答
markp-fuso
markp-fuso
发布于 2021-08-17
已采纳
0 人赞同

如果没有看到你的启动/资源文件中的实际内容(例如, ~/.bashrc ~/.profile ~/.bash_profile ,等等),我们只能猜测。

对于第二个错误信息: ./bashrc ,Renaud Pacalet已经解决了这个问题......对 bashrc 文件的不正确引用。

wrong: ./bashrc
right: .bashrc (or ~/.bashrc)

我猜想你有类似的东西。

. ./bashrc            # or
source ./bashrc

which should be:

. .bashrc             # or
source .bashrc        # or
. ~/.bashrc           # or
source ~/.bashrc

对于第一条错误信息,我猜测你已经填充了一个变量(例如,PATH),并且错误地export了这个变量。

wrong: export $PATH    # contents of PATH variable are exported
right: export PATH     # variable is exported
$ x='/home/shameen:/usr/bin:/usr/local/bin'
$ export x
    # no output, just a new prompt; this means the variable was successfully exported