I have an expression like following in a bash script:
if test $year % 4 -eq 0
but it's throwing a warning line 5: test: too many arguments
what is the problem here? how I can fix this?
The test builtin doesn't do arithmetic; it doesn't understand the % notation.
If you really want to use test, then you could write:
if test $((year % 4)) -eq 0
(using arithmetic expansion; the $((year % 4)) bit gets replaced with the relevant value before test is invoked); but I think it's simpler and clearer to write:
if ((year % 4 == 0))
(using an arithmetic expression instead).