0
我試圖使用echo命令從可變打印一些特定的詞(即在其中具有文本)作爲以下的可變特定詞:回聲從含有文本
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
結果是一噸的空行。我想這個問題是在echo命令,但我也不太清楚 的$變量包含的格式文本:
word1line1|word2line1|word3line1
word1line2|word2line2|word3line2
預期成果是:
word1line1
word1line2
.
.
etc
如果我使用$ {first [2]},我想要結果word2而不是word1
你有什麼'$ variable'的內容是什麼? – Inian
很多行的形式爲:word1 | word2 | word3 | word4等。 –
和你的預期輸出是什麼? – Inian