I am working on a remote server through putty and am trying to set certain environment variables throught something like this
#!/bin/bash
VAR="SOME VALUE"
export $VAR
when I exit the script and run echo on $VAR, I am given a blank line. could you please suggest a way around this.
First you need to export VAR, rather than $VAR.
Plus, I think, you are trying to execute the script from your shell as
./initVars.sh # or whatever is your script name...
You should rather source it as
source ./initVars.sh # OR
. ./initVars.sh # Note the leading '.' which serves as short-hand for source.
You can put it in your .bashrc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With