I have a multi line variable in my bash script and wanted to iterate through each line of a variable.
To do this task I am using while loop.
Following is my variable:
var="a b c d e"
As I mentioned to loop through my multi line variable(var) I am using while as shown below:
while read -r line do echo "line: $line" done <<< "$var"
Just carefully observer last line in above code, here I am using three less than symbols(<<<) and variable in double quotes.
Above example only works with bash.