Leap year in linux
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
Can I know how to show a leap year between 2014-2020 in a Linux terminal?
Is there any way using some code like $cal
- anything to show which year is leap year between 2014-2020 straightaway?
command-line
New contributor
lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
1
down vote
favorite
Can I know how to show a leap year between 2014-2020 in a Linux terminal?
Is there any way using some code like $cal
- anything to show which year is leap year between 2014-2020 straightaway?
command-line
New contributor
lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3
stackoverflow.com/questions/32196628/…
– Rinzwind
2 hours ago
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Can I know how to show a leap year between 2014-2020 in a Linux terminal?
Is there any way using some code like $cal
- anything to show which year is leap year between 2014-2020 straightaway?
command-line
New contributor
lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Can I know how to show a leap year between 2014-2020 in a Linux terminal?
Is there any way using some code like $cal
- anything to show which year is leap year between 2014-2020 straightaway?
command-line
command-line
New contributor
lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 2 hours ago


Yufenyuy Veyeh Dider
921823
921823
New contributor
lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 2 hours ago
lee
61
61
New contributor
lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3
stackoverflow.com/questions/32196628/…
– Rinzwind
2 hours ago
add a comment |Â
3
stackoverflow.com/questions/32196628/…
– Rinzwind
2 hours ago
3
3
stackoverflow.com/questions/32196628/…
– Rinzwind
2 hours ago
stackoverflow.com/questions/32196628/…
– Rinzwind
2 hours ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
You can make use of date
's exit code to check for a leap year, relying on date
's behaviour of generating a non 0 exit code for an invalid date, obviosuly there's no 29th of Feb in a non-leap year:
date -d $year-02-29 &>/dev/null
echo $?
as a function:
isleap() echo is not leap;
Usage:
$ isleap 2019
is not leap
$ isleap 2020
is leap
Regarding your question:
Can i know how to show leap year between 2014-2020 in linux terminal?
echo "Leap years between 2014 and 2020:";
for y in 2014..2020; do
date -d $y-02-29 &>/dev/null && echo $y;
done
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
You can make use of date
's exit code to check for a leap year, relying on date
's behaviour of generating a non 0 exit code for an invalid date, obviosuly there's no 29th of Feb in a non-leap year:
date -d $year-02-29 &>/dev/null
echo $?
as a function:
isleap() echo is not leap;
Usage:
$ isleap 2019
is not leap
$ isleap 2020
is leap
Regarding your question:
Can i know how to show leap year between 2014-2020 in linux terminal?
echo "Leap years between 2014 and 2020:";
for y in 2014..2020; do
date -d $y-02-29 &>/dev/null && echo $y;
done
add a comment |Â
up vote
3
down vote
You can make use of date
's exit code to check for a leap year, relying on date
's behaviour of generating a non 0 exit code for an invalid date, obviosuly there's no 29th of Feb in a non-leap year:
date -d $year-02-29 &>/dev/null
echo $?
as a function:
isleap() echo is not leap;
Usage:
$ isleap 2019
is not leap
$ isleap 2020
is leap
Regarding your question:
Can i know how to show leap year between 2014-2020 in linux terminal?
echo "Leap years between 2014 and 2020:";
for y in 2014..2020; do
date -d $y-02-29 &>/dev/null && echo $y;
done
add a comment |Â
up vote
3
down vote
up vote
3
down vote
You can make use of date
's exit code to check for a leap year, relying on date
's behaviour of generating a non 0 exit code for an invalid date, obviosuly there's no 29th of Feb in a non-leap year:
date -d $year-02-29 &>/dev/null
echo $?
as a function:
isleap() echo is not leap;
Usage:
$ isleap 2019
is not leap
$ isleap 2020
is leap
Regarding your question:
Can i know how to show leap year between 2014-2020 in linux terminal?
echo "Leap years between 2014 and 2020:";
for y in 2014..2020; do
date -d $y-02-29 &>/dev/null && echo $y;
done
You can make use of date
's exit code to check for a leap year, relying on date
's behaviour of generating a non 0 exit code for an invalid date, obviosuly there's no 29th of Feb in a non-leap year:
date -d $year-02-29 &>/dev/null
echo $?
as a function:
isleap() echo is not leap;
Usage:
$ isleap 2019
is not leap
$ isleap 2020
is leap
Regarding your question:
Can i know how to show leap year between 2014-2020 in linux terminal?
echo "Leap years between 2014 and 2020:";
for y in 2014..2020; do
date -d $y-02-29 &>/dev/null && echo $y;
done
edited 2 hours ago


Arronical
12.7k84589
12.7k84589
answered 2 hours ago
RoVo
5,8691438
5,8691438
add a comment |Â
add a comment |Â
lee is a new contributor. Be nice, and check out our Code of Conduct.
lee is a new contributor. Be nice, and check out our Code of Conduct.
lee is a new contributor. Be nice, and check out our Code of Conduct.
lee is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1081137%2fleap-year-in-linux%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
3
stackoverflow.com/questions/32196628/…
– Rinzwind
2 hours ago