Last active
June 6, 2020 10:55
-
-
Save yuraloginoff/905696cdd85341dea399cc94c687643f to your computer and use it in GitHub Desktop.
#bash: Check for cli arguments
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
#!/bin/bash | |
# Exit if no arguments | |
[ $# -eq 0 ] && { echo "Usage: $0 param name"; exit 1; } | |
# if no command line arg given | |
# set var to Unknown | |
if [ -z $1 ] | |
then | |
var="Unknown" | |
elif [ -n $1 ] | |
then | |
# otherwise make first arg as a var | |
var=$1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment