Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using assignment 1

Status
Not open for further replies.

Yarka

Technical User
Jan 14, 2007
192
ES
Hi,

When I do:
let "a = $a % 5"
my output is:
let: a = % 5: syntax error: operand expected (error token is "% 5")
Why I obtain this error? How can I correct this?

Thanks.
 
And this ?
let a="$a % 5"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
bash should also know (( )) arythmetic as an equivalent for the let command:

(( a=a%5 ))
(( a=a % 5 ))

And there's really no need for the $s, "let" knows about the value of variables or tokens without the need for variable substitution by the shell...

let a=a%5
let a=$a%5
let a=${a}%5
let a='a % 5'
let a="a % 5"
let a="$a % 5"
let a="${a} % 5"

If you do want to use "let" and $s and spaces for clarity, you also have to use double quotes or the shell won't substitute the variable values. (Variable substitution doesn't occur inside single quotes)


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top