Reading environment variables in bash is as simple as referencing the environment variable in a command.

    echo "${ENV_NAME}"

The above example will echo the environment variable ENV_NAME.

If you need a default variable within a script to be assigned if the environment variable is empty or non-existant you can initialise the a variable using the environment variable as potential input as follows

local_dir=${ENV_LOCAL_DIR:-"/data/local"}
remote_dir=${ENV_REMOTE_DIR:-"/data/remote"}
local_file=${ENV_LOCAL_FILE:-"${local_dir}/filename"}
remote_file=${ENV_REMOTE_FILE:-"${remote_dir}/filename"}

So to break this down a little, the value of local_dir will be /data/local if the environment variable ENV_LOCAL_DIR is not set or empty.

The value of local_file will be ${local_dir} expanded as above and include /filename if the environment variable ENV_LOCAL_FILE is not set. This means that by default the value of local_file will be /data/local/filename.

By excluding the hyphen this will only use the default if the variable is unset

local_dir=${ENV_LOCAL_DIR:"/data/local"}

What this means is that if the environment variable ENV_LOCAL_DIR exists, even if blank it will be used as the value for local_dir.