Bash alias: command not found

心已入冬 提交于 2019-12-01 16:11:29

Run bash and then try the command.

Alternatively, put it in ~/.bash_profile which should be loaded automatically.

.bashrc is only read on startup. If you just modified your .bashrc then you need to get a new shell or get your current shell to see the changes applied:

  • source ~/.bashrc in your current shell (although this may cause some startup items to run twice, which could cause other issues)
  • exec bash to get a new shell
  • just open a new Terminal window

Make sure the following line is present inside .bash_profile

test -f ~/.bashrc && . ~/.bashrc

If not then add it to the beginning. This code is used by .bash_profile to load up .bashrc. If this line is not present inside .bash_profile then anything you type inside .bashrc will not be loaded.

Mohan Raj

Error:

-bash: alias: cd /opt/logs: not found alias log= "cd /opt/logs"

Solution :

Ensure there is no space after the = symbol

log="cd**  /opt/logs"

Another solution is to call your command with bash using -i -c option:

bash -i -c my_alias

I had the same issue but the weirdest solution. I was copying it from Windows machine to OS X and for some reason, the spaces used were different and when I replaced them with normal spaces, it worked. It was not tabs, I have no idea what it was.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!