So I don't know how to make getopts so that it takes every positional parameter after the argument.
What I mean by this, is the following: this is my example code:
#!/bin/bash
while getopts 'a:b:' thing_here; do
case $thing_here in
a) part_1="${OPTARG}" ;;
b) part_2="${OPTARG}" ;;
*) echo "invalid option, quitting"
exit 1 ;;
esac
done
echo "part 1 = ${part_1}"
echo "part 2 = ${part_2}"
Now what I want is the following: Input:
$: ./example_script.sh -a asd qwe zxc -b dfg 213
Output:
part 1 = asd qwe zxc
part 2 = dfg 213
But what I actually get, is the following:
part 1 = asd
part 2 =
Now I know I can do what I want to do here by enclosing the arguments as such:
$: ./example_script.sh -a 'asd qwe zxc' -b 'dfg 213'
But what I'm trying to find, is how to do this within the script and getopts itself, without having to put the quotes myself (easier for some automation).