質問

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..

This is what I did :

nano ~/.bash_profile

The file did not exist, so I went ahead created one and added the following line

export PATH={$PATH}:~/mongo/bin

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.

.....

Now even the basic commands like open, clear , grep etc would result in

-bash: clear: command not found

When I do

export $PATH

this is what shows up ...

*

-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

*

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..

Let me know if you require additional details.. My OS is mountain lion.. I had also XCode installed..

役に立ちましたか?

解決

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.

Think about this:

echo PATH

outputs

PATH

However, this

echo $PATH

outputs this:

{{/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

Therefore, to export the PATH variable, try this instead (notice the lack of dollar sign):

export 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

他のヒント

The $ sign must be placed before the curly brackets if you want the token PATH to be expanded. Anyway, you don't even need to use it, nor curly brackets, in this case:

export PATH+=:~/mongo/bin
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top