Issue
I had a script that was doing well until now, I don't now what has changed, but the script is the same.
SIZEKB=$[[(SIZE+1023)/1024]]
REQUIREDKB=$[[SIZEKB+MINFREEKB]]
Which I repeat were working ok, but now I got this error:
line 12: [(SIZE+1023)/1024]: syntax error: operand expected (error token is "[(SIZE+1023)/1024]")
line 13: [SIZEKB+MINFREEKB]: syntax error: operand expected (error token is "[SIZEKB+MINFREEKB]")
What should I change to correct the syntax, thanks!
Solution
The easiest way to write those assignment is to providean arithmetic context:
((SIZEKB=(SIZE+1023)/1024))
((REQUIREDKB=SIZEKB+MINFREEKB))
You can use also
SIZEKB=$[(SIZE+1023)/1024]
REQUIREDKB=$[SIZEKB+MINFREEKB]
but this is deprecated and provided for compatibility with old scripts (perhaps those written for bash version 1?).
Answered By - user1934428 Answer Checked By - David Marino (WPSolving Volunteer)