Created
June 9, 2022 14:20
-
-
Save moukrea/d7e0492f7d46ff81e286a5f0d222267c to your computer and use it in GitHub Desktop.
Shell - Get command line arguments
This file contains hidden or 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 | |
| args=$(getopt -o a:,b --long alpha:,beta -n "" -- "$@") | |
| if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi | |
| eval set -- "${args}" | |
| while true; do | |
| case "${1}" in | |
| -a | --alpha ) ALPHA="${2}"; shift 2 ;; | |
| -b | --beta ) BETA=gamma; shift 1 ;; | |
| * ) echo "${1}"; break ;; | |
| esac | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment