echo specific words from a variable containing text
<p>I'm trying to use the echo command to print some specific words from a variable( that has a text in it ) as following :</p>

<pre><code>for i in $variable
do
IFS="|"    # the text is in format : word1|word2|word3
first=( "$i" )
echo ${first[1]}
IFS=$OlIFS     # I have a OlIFS variable which I set in the beginning of the code as following : OlIFS=$IFS
done
</code></pre>

<p>The result is a ton of empty lines. I guess the problem is in the echo command but I'm not too sure
The $variable contains a text in the format of :</p>

<pre><code>word1line1|word2line1|word3line1
word1line2|word2line2|word3line2
</code></pre>

<p>Expected Output is :</p>

<pre><code>word1line1
word1line2
.
.
etc
</code></pre>

<p>If I use ${first[2]}, I want to have word2 as result instead of word1</p>