How to get leap year for 2006-2015

Asked by celica MONTANEZ on 2012-09-12

How to use the cal command to determine which years between 2006 and 2015 are leap years.

Question information

English Edit question
Ubuntu gnome-terminal Edit question
No assignee Edit question
Last query:
Last reply:
celica MONTANEZ (celimja) said : #1

I've tried cal -j 2006:2015 but cannot figure it out.

# This script will test if we're in a leap year or not.

year=`date +%Y`

if [ $[$year % 400] -eq "0" ]; then
  echo "This is a leap year. February has 29 days."
elif [ $[$year % 4] -eq 0 ]; then
        if [ $[$year % 100] -ne 0 ]; then
          echo "This is a leap year, February has 29 days."
          echo "This is not a leap year. February has 28 days."
  echo "This is not a leap year. February has 28 days."

is a script that tests if the year of today is a leap year.

Can you help with this problem?

Provide an answer of your own, or ask celica MONTANEZ for more information if necessary.

To post a message you must log in.