lerner
Posts: 528
Joined: Sun Mar 29, 2015 12:12 am

Cal command help.

Fri Sep 23, 2016 9:59 pm

Here is the problem:

This is what I get when I do the man cal command:

Code: Select all

-M      Weeks start on Monday.
This is what happens when I do that in the CLI:

Code: Select all

pi@PIFACE:~/Mine $ cal -M
Usage: cal [general options] [-hjy] [[month] year]
       cal [general options] [-hj] [-m month] [year]
       ncal [general options] [-bhJjpwySM] [-s country_code] [[month] year]
       ncal [general options] [-bhJeoSM] [year]
General options: [-NC31] [-A months] [-B months]
For debug the highlighting: [-H yyyy-mm-dd] [-d yyyy-mm]
pi@PIFACE:~/Mine $ 
So I am confused.
The command's MAN page shows that -M is allowed, to start weeks with Monday.
Yet, when I do the command, it rejects it.

Huh?

User avatar
rpdom
Posts: 17275
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Cal command help.

Fri Sep 23, 2016 10:08 pm

That man page shows that the -M option works with the ncal command, not cal.

Code: Select all

pi@raspi8:~ $ cal -M
Usage: cal [general options] [-hjy] [[month] year]
       cal [general options] [-hj] [-m month] [year]
       ncal [general options] [-bhJjpwySM] [-s country_code] [[month] year]
       ncal [general options] [-bhJeoSM] [year]
General options: [-NC31] [-A months] [-B months]
For debug the highlighting: [-H yyyy-mm-dd] [-d yyyy-mm]
pi@raspi8:~ $ ncal -M
    September 2016    
Mo     5 12 19 26   
Tu     6 13 20 27   
We     7 14 21 28   
Th  1  8 15 22 29   
Fr  2  9 16 23 30   
Sa  3 10 17 24      
Su  4 11 18 25      
pi@raspi8:~ $ 

lerner
Posts: 528
Joined: Sun Mar 29, 2015 12:12 am

Re: Cal command help.

Fri Sep 23, 2016 10:14 pm

Well, the error message says that - which I admit I didn't understand. - but I entered:

MAN CAL (lower case) and got the result posted.

So to me, the MAN is mis-leading.


Now, ok, ncal -M works and gives me the week starting monday.
But that is vertical but cal gives you the month horizontal.

Is this the start of a confusing journey?

:)

User avatar
Paeryn
Posts: 2987
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Cal command help.

Fri Sep 23, 2016 10:33 pm

lerner wrote:Well, the error message says that - which I admit I didn't understand. - but I entered:

MAN CAL (lower case) and got the result posted.

So to me, the MAN is mis-leading.
It isn't misleading, at the top of the man page it clearly lists which commands takes which arguments, -M is only listed for ncal.

Code: Select all

SYNOPSIS
     cal [-3hjy] [-A number] [-B number] [[month] year]
     cal [-3hj] [-A number] [-B number] -m month [year]
     ncal [-3bhjJpwySM] [-A number] [-B number] [-s country_code] [[month]
         year]
     ncal [-3bhJeoSM] [-A number] [-B number] [year]
     ncal [-CN] [-H yyyy-mm-dd] [-d yyyy-mm]
She who travels light — forgot something.

lerner
Posts: 528
Joined: Sun Mar 29, 2015 12:12 am

Re: Cal command help.

Fri Sep 23, 2016 10:40 pm

Yeah, ok, now after really looking I admit it also includes ncal.

But I seem to be put off that although it declares ncal as an alternative command, I asked for CAL.
Not NCAL.
So if I enter: MAN CAL, I am expecting the commands for CAL. If I wanted the commands for NCAL, I would have entered MAN NCAL.

But that's me.

Now I know, I shall try to be more diligent reading MAN pages in the future.

jbudd
Posts: 1446
Joined: Mon Dec 16, 2013 10:23 am

Re: Cal command help.

Fri Sep 23, 2016 10:49 pm

ncal -b displays the days across the top,

On my Pi ncal starts the week with monday anyway but maybe that's part of the locale settings. Anyway ncal -Mb should work.

ps man pages are often impenetrable and confusing. Probably better for jogging the memory than learning from.

lerner
Posts: 528
Joined: Sun Mar 29, 2015 12:12 am

Re: Cal command help.

Fri Sep 23, 2016 11:13 pm

Thanks.

Seems I need ncal -bM

User avatar
Paeryn
Posts: 2987
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Cal command help.

Fri Sep 23, 2016 11:53 pm

There are a lot of cases where man pages cover more than one thing, they will all be related however. This is helpful where they are variations of a similar thing.

In this case you have the original cal and the newcal, both programs do the same thing but in different ways. By having them in the same man page you immediately get to see both choices and you can decide which you need to use to get what you want without having to switch between 2 sets of man pages.
She who travels light — forgot something.

W. H. Heydt
Posts: 12785
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Cal command help.

Sat Sep 24, 2016 4:45 am

jbudd wrote: ps man pages are often impenetrable and confusing. Probably better for jogging the memory than learning from.
That's probably because the man pages started life as the programmers reference manual. They're for looking things up more that learning from. *Most* manuals are like that.

If the man pages are to opaque to learn from, use your favorite search engine for instructional materials.

User avatar
dasmanul
Posts: 502
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: Cal command help.

Sat Sep 24, 2016 6:39 am

On a side note, cal and ncal are actually the same program:

Code: Select all

$ ls -l /usr/bin/cal
lrwxrwxrwx 1 root root 4 Oct 28  2014 /usr/bin/cal -> ncal

lerner
Posts: 528
Joined: Sun Mar 29, 2015 12:12 am

Re: Cal command help.

Sat Sep 24, 2016 7:58 am

So please indulge my stupid question to why does cal -M not work, but ncal -M does?

User avatar
Paeryn
Posts: 2987
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Cal command help.

Sat Sep 24, 2016 9:25 am

lerner wrote:So please indulge my stupid question to why does cal -M not work, but ncal -M does?
cal -M doesn't work because that isn't a valid option for cal.

Probably ncal started out as a separate program with its separate options, then the two programs merged. Either that or when they wanted to update it they wanted to change the options so for backwards compatability the old behaviour was retained if called as cal. Or something.

When the actual cal program gets run it checks what name was used to run it so that it can respond and behave appropriately.
She who travels light — forgot something.

mfa298
Posts: 1387
Joined: Tue Apr 22, 2014 11:18 am

Re: Cal command help.

Sat Sep 24, 2016 9:58 am

lerner wrote:So please indulge my stupid question to why does cal -M not work, but ncal -M does?
Often these tool have been around in the *nix world for decades. This may mean there's no desire to change how the original program worked as that has the potential to break a lot of things.

Return to “Beginners”