mac下bash_profile文件修改后出错

将原先的bash_profile中的PATH环境变量中的$PATH删除了,然后执行source ~/.bash_profile之后就出现了错误,每次打开Terminal都显示:
-bash: grep: command not found
-bash: grep: command not found
env: bash: No such file or directory
env: bash: No such file or directory
env: bash: No such file or directory
env: bash: No such file or directory
env: bash: No such file or directory
-bash: grep: command not found
-bash: cat: command not found
-bash: grep: command not found
-bash: grep: command not found
-bash: grep: command not found
-bash: grep: command not found
所有的命令都不能正常执行了,类似:top、ifconfig
都会显示:-bash: top: command not found

还请大家帮忙看看怎样恢复???

阅读 34.7k
3 个回答

确定你的编辑器的目录位置,比如为/usr/bin/vim, 然后输入命令时用全路径: /usr/bin/vim ~/.bash_profile 打开上面的文件后,至少加上

PATH=/bin:/sbin/ 
export PATH 

估计这样就可以恢复原来的样子了

  1. 打开Terminal

  2. 重置$PATH
    $ export PATH=/bin:/usr/bin:/usr/local/bin

  3. 修复$PATH

新手上路,请多包涵

楼主我也遇到了同样的问题,你是怎么解决的。我直接输入 pico .bash_profile提示not found 后来我按照上面的方法输入/usr/bin/vim ~/.bash_profile后出来了我之前的那些export,但是有个地方错了,我始终修改不了。修改了会出来另外一个.swp文件。楼主你是如何修改的?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题