Shell Script if Statement Conditions

Asked 2 years ago, Updated 2 years ago, 107 views

It is the condition of the if statement to check leap year.

if[ ((${year}%4 -eq 0 ) && (${year}%100 -ne 0 )) || (${year}%400 -eq 0) ] then ... fi

The conditions I put in are, "Once every four years, a year that is not a multiple of 100 or a year that is a multiple of 400." It's an index

syntax error near unexpected token `then'

` then'

There's an error like this..

Please help me.

linux shell-script if문

2022-09-20 19:49

1 Answers

Do it like this.

if (($year % 4 == 0 )) && (($year % 100 != 0 )) || (($year % 400 == 0))


2022-09-20 19:49

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.