kadamb
kadamb

Reputation: 1738

What does “-z” does exactly in a shell script?

I have got this script,I know what is happening in the first line and the if block, but cant understand the if condition.

pid5=$(ps aux | grep -w "consumer-1.0.jar general" | grep -v grep | awk '{print $2}')

        if [ -z "$pid5" ]; then
            kill -9 "$pid5" 
        fi

I searched on google and SO too, but couldnt find any help.

Upvotes: 1

Views: 78

Answers (1)

Rahul Tripathi
Rahul Tripathi

Reputation: 172438

See the man page it says:

`-z String'

 True if the length of String is zero.

Upvotes: 2

Related Questions