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?
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?
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.)