I am beginner and I have a doubt in shell script.I'm doing some examples following this tutorials as:and I was curious to know if there is this kind of function in shell (var_dump PHP) because I Googled and found nothing.For following these tutorials I'm trying to do something useful and have the following example:pids=$(ps -C pidgin -o pid=)if [ -z $pids ]; then echo have pids $pids else echo do not have pids $pidsfiBut I can not validate the variable 'pids' even with -n or -z or ! $pidsalways prints the number of pidgin pids even in if or else conditionRunning on terminal show this:bash: [: 2480: binary operator expecteddo not have pids 2480 20700How can I property make this sentence work for this example?Thanks
Is there a function in shell script equivalent a var_dump(PHP)
shell script
You should quote it like this:if [ -z $pids ]If you ever find yourself using a variable outside of quote marks, you're probably doing it wrong.