I am a newbie to UNIX. I am using mac OS X 10.8. I created .profile under home directory. However, it does not work when login. I always have to force it to work using the command $ . ~/.profile. Can anyone explain it for me?
Another question, I try to write a Cshell name wld and make it executable. However, I cannot call it just by typing $ wld. I have to type $./wld. How to make it work normally?
1 Answer
~/.profile is not read by bash, if ~/.bash_profile or ~/.bash_login exists. Also remember that ~/.profile is executed by the command interpreter for login shells and ~/.bashrc is executed for non-login shells. You can read more here:
Scripts are usually placed in ~/.bashrc and there is this code in ~/.profile:
# if running bash
if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi
fi 3