Skip to content
Advertisement

Cannot assign variable in for-loop in shell script

I tried to assign variable a in for-loop:

JavaScript

But when I run, it gave error:

JavaScript

Why did it give error? How to assign variable a?

Advertisement

Answer

There can be no spaces on both sides of the equal sign when defining variables in the Shell.

It should be:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement