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 very good Article. On high level I am anba
View Tutorial          By: Sandeep at 2010-08-27 00:40:22

2. It worked for me. Thanks a lot. Hi Sasikumar, I th
View Tutorial          By: Ramlak at 2007-03-05 01:53:14

3. Whenever i run this program, it terminates immedia
View Tutorial          By: Salman at 2015-03-26 08:23:32

4. Hi,
I run the program on windows (connectin

View Tutorial          By: Razvan at 2010-10-13 06:04:24

5. PLEASE I WANT A CODE TO BE PUT BEHIND A BUTTON SO
View Tutorial          By: KALUSHA at 2012-07-02 12:32:56

6. Dear author
u missed check condition for 0(

View Tutorial          By: Maroof Ahmad at 2012-03-28 14:59:53

7. plz give me for css coding
View Tutorial          By: anil mani at 2008-04-19 01:20:06

8. Awesome information
View Tutorial          By: Pavan Somu @ Tech Tips at 2013-01-03 18:45:30

9. Dear !

Thanks for the article. Now

View Tutorial          By: Mubasher at 2013-05-04 11:37:52

10. Sir if i wnna to take the input from user then it
View Tutorial          By: Vivek at 2011-05-14 05:56:30