How can I check if a command exists in a shell script? [duplicate]

I am writing my first shell script. In my script I would like to check if a certain command exists, and if not, install the executable. How would I check if this command exists?

if # Check that foobar command doesnt exist
then
    # Now install foobar
fi

8 Answers
8

Leave a Comment