Skip to content
Advertisement

Setting environment variables in Linux using Bash

In tcsh, I have the following script working:

#!/bin/tcsh
setenv X_ROOT /some/specified/path

setenv XDB    ${X_ROOT}/db
setenv PATH   ${X_ROOT}/bin:${PATH}

xrun -d xdb1 -i $1 > $2

What is the equivalent to the tcsh setenv function in Bash?

Is there a direct analog? The environment variables are for locating the executable.

Advertisement

Answer

export VAR=value will set VAR to value. Enclose it in single quotes if you want spaces, like export VAR='my val'. If you want the variable to be interpolated, use double quotes, like export VAR="$MY_OTHER_VAR".

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement