0
I'm Getting a "Too many arguments" error in a shell script. Can anyone explain me the cause of the error? Thank You.
Here is the code: #!/bin//bash -x read -p "Enter a year: " year if [ $(( $year % 4 )) -eq 0 -a $(( $year % 100 )) -ne 0 ] -o [ $(( $year % 400 )) -eq 0 ] then echo "The year is a leap year" else echo "The year is not a leap year" fi
4 Respuestas
+ 2
Anurag Mondal I guess it happens because the string is split to multiple arguments. Using " we can hold it together.
+ 2
Try wrapping variable output in double quotes
0
Yes I finally figured it out. Can you explain why I need to do it? Lijo M Loyid
0
Oh okay..thanks...but in the above case the input is of integer type...why is it still throwing me an error? Lijo M Loyid