I have this code:
for i in 'some text' "some other text"
do
echo $i
done
The output is:
some text
some other text
Why the spaces are not being printed?
I have this code:
for i in 'some text' "some other text"
do
echo $i
done
The output is:
some text
some other text
Why the spaces are not being printed?
Because it expands to
echo some text
which will result in the output you gave. That is why we should quote our variables in most cases. Try to replace echo $i with echo "$i" and see the difference.
Quote your expansions echo "$i":
$ for i in 'some text' "some other text"
do
echo "$i"
done
Prints
some text
some other text
Please read.