Try this:
var=($(./inner.sh))
# And then test the array with:
echo ${var[0]}
echo ${var[1]}
echo ${var[2]}
Output:
first
second
third
Explanation:
- You can make an array in bash by doing
var=(first second third)
, for example. $(./inner.sh)
runs theinner.sh
script, which prints outfirst
,second
, andthird
on separate lines. Since we don’t didn’t put double quotes around$(...)
, they get lumped onto the same line, but separated by spaces, so you end up with what it looks like in the previous bullet point.