The .bash_profile
is one of the startup files used by bash shell to set up the shell configuration.
In some systems, we may not find the file .bash_profile
. In such cases, the shell looks for the file .profile
.
We can also create the file .bash_profile
and define functions or environment variables in it.
We can use the syntax below to reload the .bash_profile
.
. ~/.bash_profile
Let's look at an example of this.
#move to directory cd ~/ #create bash profile touch .bash_profile #write into bash profile file cat > .bash_profile <<- EOM echo "Bash Profile execution starts.." URL="https://www.educative.io/" echo "Bash Profile execution stops.." EOM #reload the bash profile . ~/.bash_profile
In the code snippet above:
.bash_profile
since it is not available in this system..bash_profile
file..bash_profile
file using the command . ~/.bash_profile
.After executing the terminal, we can see that the bash profile is reloaded. We can use echo $URL
to print the environment variable value that we defined in the .bash_profile
file.
RELATED TAGS
CONTRIBUTOR
View all Courses