Assigning a bash variable to be a list of two word strings

Viewed 7322

I want to assign a bash variable to be a collection of two word segments. The bash variable is similar to a list of strings, where each string is two separate words enclosed within quotation marks). I am then trying to use this variable within a for loop so that the loop variable is assigned to one of the two word segments each iteration.

Here is my code:

#!/bin/bash
variable='"var one" "var two" "var three"'
for i in $variable
do
   echo $i
done

The output I would like is :

var one
var two
var three

But what I am getting at the moment in

"var
one"
"var
two"
"var
three"
1 Answers
Related