Ravi
Ravi

Reputation: 249

expr: non-integer argument error in Cygwin

I am using notepad++ editor and executing the shell script in Cygwin terminal.

x=5
y=6
z=`expr x + y`
echo $z

Following error is seen:

expr: non-integer argument

What is wrong with the script?

Upvotes: 0

Views: 943

Answers (1)

varro
varro

Reputation: 2482

You have to dereference the variables:

z=`expr $x + $y`

Also, make sure your script has POSIX line endings (LF), not DOS-style (CRLF) line endings. (Use dos2unix or similar to convert.)

Upvotes: 3

Related Questions