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
-zis an operator used by the[/testcommand, not a testing construct in general. Unlike in Perl, whereprint -z "file.txt"actually does test if the file is an empty file (it just prints an empty string if not, so not really useful like that).