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. This is great, hope to learn more from this commun
View Tutorial          By: Wamaguru at 2014-07-12 09:05:30

2. #include<iostream>
#include<conio.

View Tutorial          By: Zohaib Farooq at 2011-05-23 07:58:44

3. can any one plz send me the message passing codin
View Tutorial          By: sowmya at 2010-08-02 04:57:22

4. nice cursor beside learn java...but i do not know
View Tutorial          By: yazidie_y at 2008-03-08 03:33:03

5. Hi,
i am working on ocap xlet project. here

View Tutorial          By: swati at 2012-07-09 08:39:13

6. could you plz tell me how to run this all programs
View Tutorial          By: abhishek at 2010-10-27 00:08:57

7. This works great, just remember to add <uses-pe
View Tutorial          By: Nick at 2012-06-20 07:37:15

8. I got the solution people. just do the following a
View Tutorial          By: Nicholas Ndegwa at 2011-05-03 03:05:03

9. more daitlled coding for me
View Tutorial          By: fred at 2008-07-15 05:56:49

10. Thanks ... nice one with clear picture.
View Tutorial          By: Nithin at 2012-04-01 06:58:41