I need to add two numbers to a positional argument $1 with a dash between them i.e. "15-20". It is an interval from 15 to 20 and it has to be a one positional parameter. I did this:
a=$(echo "$1" | sed 's/-/ /g')
bash you can use process substitution:
read a b < <(echo "$1" | sed 's/-/ /g') # and check values declare -p a b declare -- a="15" declare -- b="20"
As the helpful comment from @chepner below, you don't even need
sed. You can use read both variables using a custom
IFS=- read a b <<< "$1"