Skip to main content
1 of 2
JoeMjr2
  • 161
  • 1
  • 1
  • 3

Check if environment variable is set from the command line

I want to know if a particular environment variable is set or not, from the command line. I need to distinguish between it being set to a blank string (or just whitespace) and not set at all, so I'd like to get a definitive True/False or Yes/No, not just printing nothing if it's not set.

I know that in a script, I can use "-z", but I'm not sure if/how I can do it directly from the command line.

I tried this: $ echo -z "${MY_URDSFDFS}"

But it just prints: -z

JoeMjr2
  • 161
  • 1
  • 1
  • 3