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. i Want the Flow Chart for the Calendar Demo Progra
View Tutorial          By: Narayanan V at 2010-01-06 18:57:25

2. Easy to understand.good work
View Tutorial          By: Deepika at 2013-12-13 09:33:55

3. what will be the output of 'X' in following code a
View Tutorial          By: Amit Goyal at 2009-09-25 05:48:45

4. Good
View Tutorial          By: sirisha at 2009-09-08 23:04:22

5. This is great, hope to learn more from this commun
View Tutorial          By: Wamaguru at 2014-07-12 09:05:30

6. excellent..... thanks it help me a lot.......
View Tutorial          By: REJAPUTRA at 2009-10-23 09:19:25

7. Error...!!
please send correct java code fo

View Tutorial          By: mayuri at 2013-10-20 13:26:30

8. Good stuff and good example to support it.
View Tutorial          By: tabrez at 2012-04-10 01:44:48

9. I'm trying to learn navigating between activities.
View Tutorial          By: Ben at 2012-01-17 23:42:38

10. thnks for the loop
View Tutorial          By: Benavidez,Jam at 2010-02-02 01:57:48