I would like to split a variable containing two numbers delimited by a comma
and transfer the two numbers into two variables p and q.
Input:
var="{5,8}"
Output:
p=5
q=8
var="{5,8}"
IFS=, read p q <<< "${var//[\{\}]/}"
echo "p=$p"
echo "q=$q"
--
Chris F.A. Johnson <http://cfajohnson.com/>
=========================== Author: ===============================
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Pro Bash Programming: Scripting the GNU/Linux shell (2009, Apress)