Skip to content

Instantly share code, notes, and snippets.

@glava
Created January 15, 2016 13:28
Show Gist options
  • Save glava/c2aa1ccd8c04374cf7f0 to your computer and use it in GitHub Desktop.
Save glava/c2aa1ccd8c04374cf7f0 to your computer and use it in GitHub Desktop.
argument parsing
#!/bin/bash
while getopts ":i:o:s:" opt; do
case $opt in
s)
ss=$OPTARG
;;
i)
input=$OPTARG
;;
o)
output=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
echo $input
echo $output
echo $ss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment