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



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 Very nice explanation...
View Tutorial          By: anil at 2010-11-04 00:22:58

2. I have a mac book dual booting with snow leopard (
View Tutorial          By: david at 2015-06-27 15:33:07

3. my requirement is i have a source string as src{&q
View Tutorial          By: Anil at 2014-10-27 08:36:23

4. sir... i made a program just like that ... but the
View Tutorial          By: David at 2010-07-08 03:34:13

5. pretty good explanation
View Tutorial          By: Prithwi at 2009-11-26 07:28:33

6. I Want To Know More About Windows Azure Advantages
View Tutorial          By: sathish at 2010-08-31 10:23:10

7. For Jaime,

Maybe using JavaScript f

View Tutorial          By: Jair Aviles at 2011-11-22 05:49:05

8. Hi got an error while executing :

j

View Tutorial          By: Hi, at 2009-07-06 01:09:35

9. very simple and nice examples for begineer...
View Tutorial          By: sarhand at 2010-04-21 00:57:23

10. very good example..
View Tutorial          By: vignesh.m at 2010-06-16 05:00:02