Reputation: 2826
I'm writing a bash script to run a ruby command and it requires a few gems. I'm checking if the gem is installed and installing it like so:
if ! gem list rest-client -iq
then
echo "Missing rest-client gem, installing now..."
gem install rest-client
fi
This works great, except for the fact that is outputs true
or false
. Looking at the help pages, I think adding the q
option is suposed to silence this output, however I may be wrong.
How do I go about suppressing the true
or false
output and just act on it?
Upvotes: 1
Views: 276
Reputation: 289725
As indicated in the comments, just redirect the stdout
to /dev/null
so that it does not show:
if ! gem list rest-client -iq >/dev/null
# ^^^^^^^^^^
then
echo "Missing rest-client gem, installing now..."
gem install rest-client
fi
Upvotes: 1