I have created env.sh file the contents of which are below#!/bin/shexport M2_HOME=/vagrant/tools/mavenexport PATH=$PATH:$M2_HOME/binexport JAVA_HOME=/usr/lib/jvm/jdk1.7.0_65export ANT_HOME=/usr/local/apache-ant-1.9.7export MAVEN_HOME=$M2_HOMEbut executing this sh file does not result in env variables being exported. Have to manually execute each line to get them exported. Please help
Setting up environment variables with .sh file
shell;ubuntu;environment variables
You need to source (.) the file, not execute:. env.shWhen you execute the script, it is run in a subshell, and all the parameters exported will go out of scope once the (sub)shell exits, not affecting the parent shell.When you source it, the parameters will be available on the calling session. And also on the child processes as you are export-ing them. Note that, the default system shell (sh) for Ubuntu is dash, not bash and gnome-terminal spawns bash as the interactive shell. While executing, make sure the shebang is correct, and desired one. Also while source-ing, no need for the shebang, you can drop it.