2 added 238 characters in body
source | link

I have a bashscript, which executes a command and calculates a pair of values, which output can look like this.

a,b (10.0000000000, 10.0000000000) -> volt (2088133.7088034691, -222653.3238934391)

And in case of invalid parameters or errors the program can show different error-messages.

Is there a safe way to parse the two volt-values and store them in two variables in a bash script?

Edit: Solution thanks to @jasonwryan and @KasiyA

variable=$([program call])

read var1 var2 <<< $(awk -F"[)(, ]" '{printf "%s\n%s\n", $(NF-3),$(NF-1)}' <<< "$variable")

echo "val1 = $var1"
echo "val2 = $var2"

I have a bashscript, which executes a command and calculates a pair of values, which output can look like this.

a,b (10.0000000000, 10.0000000000) -> volt (2088133.7088034691, -222653.3238934391)

And in case of invalid parameters or errors the program can show different error-messages.

Is there a safe way to parse the two volt-values and store them in two variables in a bash script?

I have a bashscript, which executes a command and calculates a pair of values, which output can look like this.

a,b (10.0000000000, 10.0000000000) -> volt (2088133.7088034691, -222653.3238934391)

And in case of invalid parameters or errors the program can show different error-messages.

Is there a safe way to parse the two volt-values and store them in two variables in a bash script?

Edit: Solution thanks to @jasonwryan and @KasiyA

variable=$([program call])

read var1 var2 <<< $(awk -F"[)(, ]" '{printf "%s\n%s\n", $(NF-3),$(NF-1)}' <<< "$variable")

echo "val1 = $var1"
echo "val2 = $var2"
1
source | link

Get two values from command output in a bash script

I have a bashscript, which executes a command and calculates a pair of values, which output can look like this.

a,b (10.0000000000, 10.0000000000) -> volt (2088133.7088034691, -222653.3238934391)

And in case of invalid parameters or errors the program can show different error-messages.

Is there a safe way to parse the two volt-values and store them in two variables in a bash script?