Bash: test for an empty variable

Today I needed to test if a bash variable was a null string. To do that you use the -z operator. To test if a variable is non-null you use the -n operator. Here is a quicky script sample I wrote to check if ushare is running, and if not start it.

if [[ -z $(pidof ushare)]]; then
    ushare --content /home/share/ --name Basement --daemon
Leave A Reply
All content licensed under the Creative Commons License