.bash_profile 损坏未找到,命令未找到...帮助恢复到原来的 [英] .bash_profile corrupted not found, command not found... Help restore it back to the original
问题描述
我正在我的 mac 上安装 Mongo db ......并且将 Mongodb/bin 目录导出到 PATH .. 看起来我损坏了 bash_profile,现在我找不到它..
I was playing with the installation of Mongo db on my mac... and in exporting the Mongodb/bin dir to PATH .. looks like I corrupted the bash_profile and now I can't find it..
这就是我所做的:
nano ~/.bash_profile
该文件不存在,所以我继续创建一个并添加以下行
The file did not exist, so I went ahead created one and added the following line
export PATH={$PATH}:~/mongo/bin
所以现在我通过按 ctrl + O 保存文件 .. 然后在提示符下按 Enter.然后我按 ctrl + X 退出 nano.我使用以下命令重新加载了我的 bash 配置文件:
So now I saved the file .. by pressing ctrl + O and then hit Enter at the prompt. Then I pressed ctrl + X to exit nano. I reloaded my bash profile with the following command:
$ source ~/.bash_profile.
.....
现在,即使是 open、clear、grep 等基本命令也会导致
Now even the basic commands like open, clear , grep etc would result in
-bash: clear: command not found
当我这样做
export $PATH
这就是显示...
*
-bash: export: `{{/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin}:/Users/pavbond007/Documents/Mongo/mongodb-osx-x86_64-2.2.3/bin}:/Users/pavbond007/Documents/Mongo/mongodb-osx-x86_64-2.2.3/bin':不是有效的标识符
-bash: export: `{{/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin}:/Users/pavbond007/Documents/Mongo/mongodb-osx-x86_64-2.2.3/bin}:/Users/pavbond007/Documents/Mongo/mongodb-osx-x86_64-2.2.3/bin': not a valid identifier
*
我是这方面的新手.. 请帮助我回到我可以访问所有 mac 和 unix 命令的原始状态..
I am a novice in this.. Please help me get back to my original state where I had access to all the mac and unix commands..
如果您需要更多详细信息,请告诉我..我的操作系统是山狮..我还安装了 XCode..
Let me know if you require additional details.. My OS is mountain lion.. I had also XCode installed..
推荐答案
我怀疑问题是 $PATH 在您不希望的情况下被扩展.导出命令没有任何区别对待.导出期望导出的环境变量的名称,但您没有为其提供变量的名称,而是为其提供了变量引用本身,该引用会被扩展.
I suspect the issue is that $PATH is being expanded when you don't want it to be. The export command isn't treated any differently. Export expects the name of an environment variable to export, but you aren't giving it the name of the variable, you are giving it the variable reference itself, which gets expanded.
考虑一下:
echo PATH
输出
PATH
然而,这个
echo $PATH
输出:
{{/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin}:/Users/pavbond007/Documents/Mongo/mongodb-osx-x86_64-2.2.3/bin}:/Users/pavbond007/Documents/Mongo/mongodb-osx-x86_64-2.2.3/bin
因此,要导出 PATH 变量,请改用此方法(注意缺少美元符号):
Therefore, to export the PATH variable, try this instead (notice the lack of dollar sign):
export PATH
另外,我注意到你的 $PATH 中有一堆花括号.把那些拿出来.我很确定这是破坏性的.
Also, I noticed your $PATH has a bunch of curly braces in it. Take those out. I'm pretty sure that is breaking things.
要像您第一次尝试的那样在一行中完成此操作,让我们将它们放在一起:
To do this in one line like you tried first, let's bring it all together:
export PATH=$PATH:~/mongo/bin
这篇关于.bash_profile 损坏未找到,命令未找到...帮助恢复到原来的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!