I'm curious to know if we can display 5 months of a calendar using the cal command. I know we can three successive months (cal -3) but I wanted to know if we can do it with 5 months for example. (Give a specific month, and get as a result two previous months + the month in question + two next months)
As I was looking for options to use with the command cal, I found there's one : cal -con[tinue]=n which displays the next n successive months starting with the month specified. I wanted to know if there's a similar command that displays the previous n months for example?
Oh thank you ! This one works very well !
I have another question related to this subject, I have found in this website : (unix.com/man-page/Linux/1/cal/ Man Page for cal) that I can use the command cal with these options :
cal [-3hj] [-A number] [-B number] -m month [year]
knowing that :
-A number
Display the number of months after the current month.
-B number
Display the number of months before the current month.
But when I try it, I get the same message as you did (invalid option -- 'A') . I don't understand why
Okay, I will .. I'm new to this forum and I'm still discovering its features !
Unfortunately, it didn't work. I was thinking that maybe it's because I don't have the same synopsis of the command cal when I try it compared to the one on the website I took the options (A and B) from..
That documentation probably doesn't apply to your cal implemenation (it looks like the FreeBSD implementation). Those options are non-standard. Read your system's man cal instead.
That for-loop from post #2 won't work with those four months because, even if you wrap the months using modulo-12 arithmetic, the year is left unadjusted.
Yes, those 5! numbers represent the 5 months to be shown, i dont know which 5 months he wants.
Year is untouched, using the current, since i dont know which year he want to have shown either.
If you want to display the COMLPETE year 2042, your supposed to use:
Oh yeees, now I understand ! You're right, if I choose November for example, then in the two next months, I obviously have December and January of the SAME year, which isn't what I want !
Thanks for highlighting this, I didn't pay attention to that !
Shows: Feb, Apr, Jun, Aug, Oct
As it shows June 2014 with a range of 4 months, but only showing every 2nd.
The 3rd argument, to alter the range, is optional!
Default is 2.
4th argument could alter the steps it takes, 1 for each, 2 for every 2nd. etc.
Default is 1.
showMonths 6 2022
Shows April-August of 2022
Or even just:
showMonths 6
For the same timerange of the current year.
99 ~ $ showMonths 6
April 2013
Mo Di Mi Do Fr Sa So
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Mai 2013
Mo Di Mi Do Fr Sa So
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Juni 2013
Mo Di Mi Do Fr Sa So
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Juli 2013
Mo Di Mi Do Fr Sa So
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
August 2013
Mo Di Mi Do Fr Sa So
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31