2

Using cal and ncal, I know that I can display a certain number of months using various flags (for example, ncal -C -A 4 will show the current month and the 4 months after).

What I am trying, and so far failing, to do is show more than three months in a row. I guess wrapping automatically at three months probably made sense when cal was written, but my monitor has room for more than three months. (And I am trying to get a tmux layout with one pane that shows the current month, plus 4 more, all in one row; but it always shows a row of three months, then two more months below. So that tmux pane shows two months, and a lot of wasted screen.)

Terminal with commands ncal -A4 and ncal -C -A4 and their output.

I am using Ubuntu 22.04.5 LTS, on Windows 10 WSL 2. I am having trouble finding the version of ncal, but the man page is dated March 7, 2019.

0

1 Answer 1

6

Not with BSD cal/ncal alone where the maximum number of columns is hardcoded to 2 with -jb, 3 with -j or -b, or 4 (without -j nor -b).

You could try GNU cal though which can print a whole year in a given number of blocks with -b.

For instance gcal -b 2 : would print a whole fiscal year starting with the current month on 2 blocks of 6 months each. Piped to head -n 15, you'd get only the first block:

$ gcal -b2 : | head -n15 2025/2026 October November December January February March Su 5 12 19 26 2 9 16 23 30 7 14 21 28 4 11 18 25 1 8 15 22 1 8 15 22 29 Mo 6 13 20 27 3 10 17 24 1 8 15 22 29 5 12 19 26 2 9 16 23 2 9 16 23 30 Tu 7 14 21 28 4 11 18 25 2 9 16 23 30 6 13 20 27 3 10 17 24 3 10 17 24 31 We < 1> 8 15 22 29 5 12 19 26 3 10 17 24 31 7 14 21 28 4 11 18 25 4 11 18 25 Th 2 9 16 23 30 6 13 20 27 4 11 18 25 1 8 15 22 29 5 12 19 26 5 12 19 26 Fr 3 10 17 24 31 7 14 21 28 5 12 19 26 2 9 16 23 30 6 13 20 27 6 13 20 27 Sa 4 11 18 25 1 8 15 22 29 6 13 20 27 3 10 17 24 31 7 14 21 28 7 14 21 28 

Or with a different layout with -i:

$ gcal -i -b2 : | head -n13 2025/2026 October November December January February March Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa < 1> 2 3 4 1 1 2 3 4 5 6 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 6 7 5 6 7 8 9 10 11 2 3 4 5 6 7 8 7 8 9 10 11 12 13 4 5 6 7 8 9 10 8 9 10 11 12 13 14 8 9 10 11 12 13 14 12 13 14 15 16 17 18 9 10 11 12 13 14 15 14 15 16 17 18 19 20 11 12 13 14 15 16 17 15 16 17 18 19 20 21 15 16 17 18 19 20 21 19 20 21 22 23 24 25 16 17 18 19 20 21 22 21 22 23 24 25 26 27 18 19 20 21 22 23 24 22 23 24 25 26 27 28 22 23 24 25 26 27 28 26 27 28 29 30 31 23 24 25 26 27 28 29 28 29 30 31 25 26 27 28 29 30 31 29 30 31 30 

With BSD ncal, you could always post process the output to concatenate the two rows of months:

$ ncal -A4 | awk 'NR<10 {s[NR]=$0; next}; {print s[NR-9] substr($0, 5)}' October 2025 November 2025 December 2025 January 2026 February 2026 Mo 6 13 20 27 3 10 17 24 1 8 15 22 29 5 12 19 26 2 9 16 23 Tu 7 14 21 28 4 11 18 25 2 9 16 23 30 6 13 20 27 3 10 17 24 We 1 8 15 22 29 5 12 19 26 3 10 17 24 31 7 14 21 28 4 11 18 25 Th 2 9 16 23 30 6 13 20 27 4 11 18 25 1 8 15 22 29 5 12 19 26 Fr 3 10 17 24 31 7 14 21 28 5 12 19 26 2 9 16 23 30 6 13 20 27 Sa 4 11 18 25 1 8 15 22 29 6 13 20 27 3 10 17 24 31 7 14 21 28 Su 5 12 19 26 2 9 16 23 30 7 14 21 28 4 11 18 25 1 8 15 22 
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.