• Home
  • Map
  • Email: mail@besthelp.duckdns.org

Syntax error operand expected error token is 2

Replace the for loop with for i in do - add double quotes. This will keep each element as its own word. Replace line 37 with searchDirectory " $ i". Remove the space which was just after to = symbol and put the command inside $ ( ), so that it would parse. log= $ ( who | grep $ 1 | cut - c 30- 31, 33- 34). And, time= $ ( date | cut - c 12- 13, 15- 16). sh: line 11: 1+ : syntax error: operand expected ( error token is " + " ). If you do var= $ is what you' ll get. Without the $, undefined variables default to 0, where in the OP' s case he is at least getting an error. Line 6 of your script expects arguments 1 to 5 to exist. If you run your script with no arguments $ 1+ $ 2+ $ 3+ $ 4+ $ 5 will becomewhich explains the error message. ( A similar explanation is valid for the second error. You never set a value for a1, so the arithmetic statement ( ( $ a1> $ a2) ) expands to ( ( > ) ). Perhaps you meant a1= $ num1 instead of num1= $ a1, but you don' t need a1 at all; you can just use $ num1.

  • Fatal error compiling java lang runtimeexception javax annotation processing filerexception
  • Pnp detected fatal error in windows 10
  • Excel vba on error goto message box
  • Php fatal error unknown failed opening required var www html


  • Video:Expected token error

    Error operand token

    The same holds for a2 and. bash script error let: - : syntax error: operand expected ( error token is “ - ” ). AWK= / usr/ bin/ nawk | | AWK= / usr/ bin/ awk date + " % j % Y" | $ AWK - v VERBOSE= $ 1 ' { DAYOFYEAR= $ 1 CURRENTYEAR= $ 2 DAYS= - 1 # Because it is. The actual error reason is because of uninitialized variable sum going through the first iteration of the loop. over the counter i which will produce incorrect results if you pass arguments other than 1 2 from the command- line. up vote 2 down vote. The error is in ( ( $ sum = $ 1 + $ 2) ) to add numbers in a bash script. Use arithmetic expansion: For Integer: sum= $ ( ( $ 1 + $ 2) ) sub= $ ( ( $ 1 - $ 2) ). share| improve this answer. answered Dec 8 ' 16 at 7: 46. I' m writing a script in bash and I get this error:.

    1: line 10: + : syntax error: operand expected ( error token is " + " ). Why the downvote? – Blue Ice Nov 24 ' 13 at 16: 27. Check also the - gt part, should' t it be - lt? You need to quote the expansion of $ BIRTH_ DATE to prevent word splitting on the whitespace in the value. ( It is good practice to quote all your parameter expansions, unless you have a good reason not to, for this very.