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



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. thaks sir for giving information about adding int
View Tutorial          By: vijay kumar at 2012-10-10 04:59:05

2. DON'T USE GETS!!!!!!!!!!!!!!! IT'S DANGEROUS!
View Tutorial          By: Caterpillar at 2012-04-23 13:22:42

3. Thanks for posting the JAVA source code!!
View Tutorial          By: Coder at 2010-07-29 11:41:10

4. place both comm.jar and javax.comm.properties in l
View Tutorial          By: Rania at 2010-09-14 19:52:49

5. @pooja: this method should work, although i'm sure
View Tutorial          By: Anush at 2012-07-16 08:30:58

6. Great example. To reset the initial value on readb
View Tutorial          By: Bala at 2014-07-22 04:48:34

7. To make this work with out error I had to add:
View Tutorial          By: Jester at 2009-03-26 15:25:59

8. Answer for Comment 4 :

" n=n++

View Tutorial          By: NewB_of_java at 2012-02-16 16:52:05

9. All true, but the 2FA that has been implemented fo
View Tutorial          By: Joe Bloggs at 2013-04-22 13:40:24

10. Thanks for the article. I finally finish my task a
View Tutorial          By: bali web at 2012-07-10 13:47:49