Home > Blockchain >  For Loop in Shell Scripting
For Loop in Shell Scripting

Time:11-04

I am new to shell scripting, and I've recently encountered something I didn't comprehend.

What is the difference between these two scripts:

Script 1:

COLORS="RED YELLOW GREEN"
for i in $COLORS
do
echo $i
done

Script 2:

for i in "RED YELLOW GREEN"
do
echo $i
done

From my perspective, they should have the same output, but they don't. Output:

Script 1:

RED
YELLOW
GREEN

Script 2:

RED YELLOW GREEN

Thanks a lot

  • Related