A nifty code snippet that will allow you to check for the availability of a command.


#!/bin/bash

if type "command-name" &> /dev/null; then
echo "Command exist!"
else
echo "Command does not exist! :("
fi

Used this myself for a script, where I wanted to make sure a certain command was available before continuing the script execution.
That being said; it was a bit of a pain to figure out how to do this, while searching the web for answers!
Solution discovered, solution shared.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.