Comment on Tutorial - Check for leap year in Shell Script By Vivek G



Comment Added by : notnooblikeyou

Comment Added at : 2013-01-29 15:11:30

Comment on Tutorial : Check for leap year in Shell Script By Vivek G
this is WRONG!

your IF should be:

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

that's a working script:

#!/bin/bash

read year

if [[ $(($year % 4)) == 0 && $(($year % 100)) != 0 ]] || [ $(($year % 400)) == 0 ]
then
echo "leap"
exit
fi

echo "not leap";


View Tutorial



Ask a Question

Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. very well to understand
View Tutorial          By: Siva Krishna N at 2007-02-16 23:06:07

2. Thanks for the simple tutorial on hashmaps. I am n
View Tutorial          By: ipkwena at 2013-08-19 09:02:49

3. Thanks so much useful to me.
View Tutorial          By: Bhuvan at 2012-05-31 14:57:57

4. it is really best site for the information.many ti
View Tutorial          By: panchanan ruata at 2013-05-22 09:36:37

5. its really helpfull to understand.
View Tutorial          By: rakhi at 2010-08-08 12:45:05

6. Good stuff.
View Tutorial          By: flazwbooks at 2010-07-18 05:50:50

7. it would be very helpful if you demonstrated how t
View Tutorial          By: newcoder at 2011-10-24 17:40:25

8. What if the MIDlet has an sms push registry, but o
View Tutorial          By: indra at 2011-07-08 09:21:54

9. I am looking for a J2ME programmer that can create
View Tutorial          By: Gary Wallis at 2007-10-14 15:35:00

10. The static variables are not in object scope inste
View Tutorial          By: Karthick at 2011-06-29 06:55:17