简体   繁体   中英

How can I edit bash_profile if open command does not work and hidden file does not open in mac

I tried to change something in my bash_profile but I think I mistyped something. So I can not run any terminal commands. If I post "ls" command then I get

-bash: ls: command not found

Now I can not open bash_profile also. So what can I do here. I get the below path using echo command but there was some any other path. Please help.

echo $PATH: /usr/local/bin:/usr/local/bin:

But if I write /bin/ls it works.

MacBook Pro El Capitan : 10.11.4

This is the possible answer - And I solved it using nano editor You messed up your PATH environment variable.

/bin/ls

works because you did not need PATH to find the 'ls' program. You can run ANY command by specifying its full path.

You need to re-edit your .bash_profile to either remove your PATH, or fix it. I do not know what editor you used to modify .bash_profile to begin with, but you can use

/usr/bin/nano

/usr/bin/vi (ONLY if you know vi/Vim)

/usr/bin/vim (ONLY if you know vi/Vim)

/usr/bin/emacs (I shutter to think about this)

TextWrangler (a very good free GUI text editor)

http://www.barebones.com/products/textwrangler/

Or you can just rename the current .bash_profile and start a new terminal session, then fix the renamed .bash_profile before putting it back in service

/bin/mv .bash_profile saved.bash_profile

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM