Created
December 14, 2022 07:27
-
-
Save garygan89/ed9e6ccc813ed42348c3795e52a9ad3f to your computer and use it in GitHub Desktop.
bash script to check if a command exist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# check if a program exist | |
#!/bin/bash | |
install_j2cli() { | |
echo -n "Installing j2cli Python module globally..." | |
sudo apt update && sudo pip3 install j2cli --system | |
check_exist j2 | |
} | |
check_exist() { | |
PROG_NAME="${1}" | |
echo -n "Checking if ${PROG_NAME} exist..." | |
[ $(command -v ${PROG_NAME}) ] && { echo "OK"; exit 0; } || install_j2cli | |
} | |
check_exist j2 | |
# EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment