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. Excellent!!!!!!!!!!

Tons of thanks

View Tutorial          By: Sara at 2009-06-03 05:38:59

2. I am very much thankfull to you in providing the c
View Tutorial          By: c vijaychandar at 2010-05-05 10:14:59

3. Thanks Man , You are Genius i have been looking fo
View Tutorial          By: hamza Ouni at 2015-02-22 13:38:02

4. The logo is a cup of coffee. Java is an island in
View Tutorial          By: kamal goduguluri at 2012-05-30 15:34:21

5. Hi Mirna,
U r talking abt speech to text co

View Tutorial          By: akshat at 2012-04-02 14:38:31

6. very easy way for understanding the java programmi
View Tutorial          By: praveen chandrakar at 2010-10-14 20:26:53

7. Great Job
View Tutorial          By: Niteen Dhule at 2015-02-09 06:37:03

8. Hi. I put the file .cert in two paths:
C:\P

View Tutorial          By: ALFREDO at 2012-09-18 16:22:16

9. thanks for sharing.It's Easy to Understand
View Tutorial          By: Ganesh Abothula at 2013-01-23 10:43:55

10. my query is like this: " accept a string, cou
View Tutorial          By: samtopper at 2014-07-31 17:40:25