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

Java program to get location meta data from an image

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

Archived Comments

1. Introduction is very clear I get the answer what I
View Tutorial          By: sathya at 2013-02-05 15:57:30

2. Is operator overloading possible in java??????
View Tutorial          By: rishi at 2008-11-01 23:55:55

3. HI,
I am getting this error
Error lo

View Tutorial          By: vijay bhanu at 2009-07-18 08:57:57

4. i didnot get the answer
View Tutorial          By: ramana at 2013-02-04 06:36:37

5. Its really good and helpfull..........
chee

View Tutorial          By: sumit at 2009-04-28 05:17:17

6. Very nice.
Thanks

View Tutorial          By: Kaviya at 2015-02-23 13:48:15

7. Nice one
View Tutorial          By: Kalpana at 2009-11-17 02:04:14

8. i have asked for refercing the object of main clas
View Tutorial          By: deepesh at 2012-08-20 10:33:58

9. Hi Maybelline, This is the <a href="http:/
View Tutorial          By: Daniel Malcolm at 2008-08-21 06:57:31

10. The smiple easy and best way is :)
--------

View Tutorial          By: Sandhya at 2012-06-21 06:08:25