The output of following code is not like it's intended ...
Code:
echo "Test prepending ..."
for words in "apple" "hour"
do
prepended="an $prepended $(echo "$words")"
done
echo $prepended
echo "---"
echo "Test appending ..."
for words in "apple" "hour"
do
appending=("$appending $(echo "$words") is a nice word,")
done
echo $appending
This is the output:
Code:
Test appending ...
an an apple hour
---
Test prepending ...
apple is a nice word, hour is a nice word,
But of course what I want to do in the first set of commands is to prepend the word "an" to the words "apple" and "hour" in the for-loop.
Would be very grateful for any clues! Thanks in advance!