using a variable which has content separated by spaces in shell in a for loop
0
votes
1
answer
59
views
I am trying to read a variable with spaces on prompt and trying to use in a for loop.,
For example:
Enter the items to read separated by space...
apple orange kiwi
read items
for i in "$items"
do
echo $i
...(additional operations)....
done
But shell does take the first item - apple here. What am I missing here.
Asked by sabarish tr
(1 rep)
May 8, 2024, 09:27 PM
Last activity: May 8, 2024, 11:06 PM
Last activity: May 8, 2024, 11:06 PM