mardi 26 avril 2016

how to get Logical Not in shell?

I am testing whether command exist like this:

if hash pm2 2>/dev/null; then
    echo "already exist"
else
    npm install --global pm2
fi

but in fact I just want to do this

if not exist
   install it
fi

I tried this

if [ ! hash pm2 2>/dev/null ]; then
    npm install --global pm2
fi

it is not ok

Aucun commentaire:

Enregistrer un commentaire