Created
March 16, 2023 19:20
-
-
Save dansalias/bb0b5157ae29812d1e7b6b3725a69627 to your computer and use it in GitHub Desktop.
Bash script with flags
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 | |
# usage: | |
# ./script.sh -a <value for a> -b <value for b> | |
while getopts a:b: opt | |
do | |
case $opt in | |
a) VAR_A=$opt;; | |
b) VAR_B=$opt;; | |
esac | |
done | |
: ${VAR_A:?missing flag -a} | |
: ${VAR_B:?missing flag -b} | |
echo $VAR_A $VAR_B |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment