Discussion:
date for week
(too old to reply)
Jeff Peng
2024-06-10 23:30:01 UTC
Permalink
Hello,

I run the folllowing command,

$ date +%w
2


While I expect the output should be:

$ date +%such_a_option
Tuesday

or
$ date +%such_a_option
Tue

does date command has this option?

Thanks.
Roberto C. Sánchez
2024-06-10 23:30:01 UTC
Permalink
Post by Jeff Peng
Hello,
I run the folllowing command,
$ date +%w
2
$ date +%such_a_option
Tuesday
or
$ date +%such_a_option
Tue
does date command has this option?
Thanks.
You probably want:

$ date +%a
Mon
$ date +%A
Monday
--
Roberto C. Sánchez
Jeff Peng
2024-06-10 23:50:01 UTC
Permalink
thanks roberto. that's exactly what i am looking for.
Post by Roberto C. Sánchez
$ date +%a
Greg Wooledge
2024-06-10 23:50:01 UTC
Permalink
Post by Jeff Peng
$ date +%such_a_option
Tuesday
or
$ date +%such_a_option
Tue
does date command has this option?
You can run the command "man date" to read the short version of the
documentation. This will include the information you wanted. Search
for "week" and it takes you right there:

%a locale's abbreviated weekday name (e.g., Sun)

%A locale's full weekday name (e.g., Sunday)

%b locale's abbreviated month name (e.g., Jan)

%B locale's full month name (e.g., January)

%c locale's date and time (e.g., Thu Mar 3 23:05:25 2005)

Should you ever feel a need to read the longer version of the
documentation, it's in GNU info pages. So you would need to type
the command "info coreutils date" to get to it. And then you'd need
to figure out the user interface of the "info" program, which is not
intuitive unless you happen to be an emacs power user already.
Max Nikulin
2024-06-11 16:30:01 UTC
Permalink
Post by Greg Wooledge
Should you ever feel a need to read the longer version of the
documentation, it's in GNU info pages. So you would need to type
the command "info coreutils date" to get to it. And then you'd need
to figure out the user interface of the "info" program, which is not
intuitive unless you happen to be an emacs power user already.
Emacs power users can type
M-x info RET
or
M-: (info "(coreutils) date conversion specifiers") RET
or at least
emacs -f info-standalone '(coreutils) date conversion specifiers'

I do not mind that info browsers have usability issues. For beginners I
would recommend tkinfo instead of terminal "info". I have not tried pinfo.

Texinfo, unlike man, has a notion of hyperlink. In the case of man it is
just formatting that suggests that some part of text is a reference to
another document or another section. It was created for "online" version
of printed manuals. Info is more convenient for navigation in long
document and makes it easier to specify a particular section. In the
case of man it requires some tricks like

man -P 'less -p %a' date
Greg Wooledge
2024-06-11 18:10:01 UTC
Permalink
Post by Max Nikulin
Post by Greg Wooledge
Should you ever feel a need to read the longer version of the
documentation, it's in GNU info pages. So you would need to type
the command "info coreutils date" to get to it. And then you'd need
to figure out the user interface of the "info" program, which is not
intuitive unless you happen to be an emacs power user already.
Emacs power users can type
M-x info RET
or
M-: (info "(coreutils) date conversion specifiers") RET
or at least
emacs -f info-standalone '(coreutils) date conversion specifiers'
I do not mind that info browsers have usability issues. For beginners I
would recommend tkinfo instead of terminal "info". I have not tried pinfo.
Texinfo, unlike man, has a notion of hyperlink. In the case of man it is
just formatting that suggests that some part of text is a reference to
another document or another section.
See, this is all fine -- you've searched for the appropriate section, and
you've generated a cryptic command that someone else could type inside
emacs to get to that same section. I'm sure there's an "info" equivalent
that can be done from a shell without invoking emacs.

None of that's useful to a person who wants to search for that information
in the first place without consulting an expert who's already done the
work.

What I was trying to do in my reply was "teach them how to fish" -- to
show them how to bring up the man page themselves, and look for basic
information like "how do I get the name of the day of the week, instead
of the numeric index of the day of the week" without having to bother
an international mailing list.

So, I gave basic instructions for how to bring up the man page, and a
hint about searching for a key word related to their question. I even
provided a small piece of the man page, which happens to include the
answer they're looking for, because I'm also a pessimist who knows
that they probably won't look it up themselves, and may become angry
if we don't spoon-feed them the actual answer.

I also provided a reference to the info page, and a command that would
bring that up, should the need ever arise. More importantly, I revealed
that info pages *exist* and *are a thing* that they need to know about.
It's planting a seed for the future.
Max Nikulin
2024-06-12 16:10:01 UTC
Permalink
Post by Greg Wooledge
Post by Greg Wooledge
Should you ever feel a need to read the longer version of the
documentation, it's in GNU info pages. So you would need to type
the command "info coreutils date" to get to it. And then you'd need
to figure out the user interface of the "info" program, which is not
intuitive unless you happen to be an emacs power user already.
[...]
Post by Greg Wooledge
I also provided a reference to the info page, and a command that would
bring that up, should the need ever arise. More importantly, I revealed
that info pages *exist* and *are a thing* that they need to know about.
It's planting a seed for the future.
I misunderstood your intention and I am sorry for that. I found your
words quite discouraging in respect to "info", perhaps it is just
language barrier.

Info is quite important. While e.g. "man bash" and "info bash" documents
are quite similar, there is no man equivalent for "info grub".

Your variant of info command is quite specific. I like that "info"
allows partial match of node name and it may be a separate argument.
Unfortunately tkinfo and the Emacs function require another style (info
"(coreutils) date invocation"). Every coreutils man page has it in the
"SEE ALSO" section.

I do not mind that users almost certainly familiar with basic pager UI
and using of "info" requires some knowledge. In this particular case UI
does not differ

- info "(coreutils) date invocation"
- /week [Enter]

P.S. Perhaps Emacs developers teach users how to fish as well. From my
point of view the following path described in "emacs --help" is
Post by Greg Wooledge
Run M-x info RET m emacs RET m emacs invocation RET inside Emacs to
read the main documentation for these command-line arguments.
r***@windstream.net
2024-06-10 23:50:01 UTC
Permalink
All the format codes are documented in the man page for date.
in particular:

+%a gives a short form, such as Mon
+%A gives full name, e.g. Monday
+%^a and +%^A as above, but all capital letters.

----- Original Message -----
Post by Jeff Peng
$ date +%such_a_option
Tuesday
or
$ date +%such_a_option
Tue
does date command has this option?
Yes, see above.
--
Bob Netzlof a/k/a Sweet Old Bob
Loading...