Home > Blockchain >  Setting environment path variable in bashrc not testing at command line
Setting environment path variable in bashrc not testing at command line

Time:09-21

I'm trying to understand setting variables in .bashrc and .bash-profile.

If I add something to my .bashrc, like this

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

export MMMM_HOME=/appl #added
#. ~/inits.bsh         #added
. /appl/etc/mmmm.env   #added

How can I check that it's set properly? I tried opening a new putty session, I tried typing bash, I tried at the command line [-z "$MMMM_HOME"] && echo "empty" || echo "Not empty" #-z: command not found...

I tried which MMMM_HOME and which $MMMM_HOME at the command line.

I googled it. I'm not sure about this...does anyone have any info? Thanks!

CodePudding user response:

Two spaces are missing in your test. Here's the command with the right bash syntax:

[ -z "$MMMM_HOME" ] && echo "empty" || echo "Not empty"
  •  Tags:  
  • bash
  • Related