O'Reilly logo

Korn Shell: Unix and Linux Programming Manual, Third Edition, The by Anatole Olczak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The let Command

Integer arithmetic can be done with the let command and arithmetic expressions. The format for the let command is:

					let "arithmetic-expression"
				

where arithmetic-expressions can contain constants, operators, and Korn shell variables. Double quotes are used with arithmetic expressions that contain white space or operators that have special meaning to the Korn shell. For example, variable X can be set to the sum of 1+1 like this:

					$ let "X=1 + 1"
					$ print $X
					2
				

then incremented:

					$ let "X=X + 1"
					$ print $X
					3
				

Notice that in arithmetic expressions, regular variables can be referenced by name only, and do not have to be preceded by $ for substitution to be performed. Both

					$ let "X=X + 1"
				

and

					$ let "X=$X + 1"
				

are equivalent. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required