160 points · by adius · 10y ago · 92 comments
~ $ cal 5 16
May 16
Su Mo Tu We Th Fr Sa
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
~ $ cal 5 2016
May 2016
Su Mo Tu We Th Fr Sa
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 $ cal may
May 2016
Su Mo Tu We Th Fr Sa
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
$ cal -y
2016
January February March
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 1 2 3 4 5
3 4 5 6 7 8 9 7 8 9 10 11 12 13 6 7 8 9 10 11 12
10 11 12 13 14 15 16 14 15 16 17 18 19 20 13 14 15 16 17 18 19
17 18 19 20 21 22 23 21 22 23 24 25 26 27 20 21 22 23 24 25 26
24 25 26 27 28 29 30 28 29 27 28 29 30 31
31
[...]Call me old-fashioned but I like keyboards (still)?
I've used it myself in scripts to find Julian day numbers, to count days-within-months, etc. -- for old science data -- before there were more robust ways to do this stuff.
It's hard to insert DWIM behaviors into old command-line utilities, because "what I mean" is not clear.
$ curl wttr.in/94035
My most frequently used option for cal on GNU/Linux is "-3". It shows the current, previous, and next month with the current day highlighted, which are usually all the information I need. $ cal -3
April 2016 May 2016 June 2016
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 7 1 2 3 4
3 4 5 6 7 8 9 8 9 10 11 12 13 14 5 6 7 8 9 10 11
10 11 12 13 14 15 16 15 16 17 18 19 20 21 12 13 14 15 16 17 18
17 18 19 20 21 22 23 22 23 24 25 26 27 28 19 20 21 22 23 24 25
24 25 26 27 28 29 30 29 30 31 26 27 28 29 30Part of the problem seems to be GNU Screen-- if I switch tabs, then switch back, the redraw seems to clobber some formatting characters.
EDIT: LC_CTYPE wasn't set for that user, but setting it didn't fix anything. So, who knows.
~$ cal 9 1752
September 1752
Su Mo Tu We Th Fr Sa
1 2 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30[1] https://en.wikipedia.org/wiki/Mount_Athos#Date_and_time_reck...
I don't think the 5th edition had cal.
$ man calendar
CALENDAR(1) General Commands Manual CALENDAR(1)
NAME
calendar - reminder service
SYNOPSIS
calendar [-abw] [-A num] [-B num] [-f calendarfile] [-t [[[cc]yy]mm]dd]
DESCRIPTION
The calendar utility checks the current directory or the directory
specified by the CALENDAR_DIR environment variable for a file named
calendar and displays lines that begin with either today's date or
tomorrow's. On Fridays, events on Friday through Monday are displayed.
[...] mcphage:~ $ CAL
May 2016
Mo 2 9 16 23 30
Tu 3 10 17 24 31
We 4 11 18 25
Th 5 12 19 26
Fr 6 13 20 27
Sa 7 14 21 28
Su 1 8 15 22 29 $ brew info gcal
gcal: stable 4 (bottled)
Program for calculating and printing calendars
https://www.gnu.org/software/gcal/
/usr/local/Cellar/gcal/4 (81 files, 2.8M) *
Poured from bottle on 2016-01-13 at 17:03:09
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/gcal.rb
==> Dependencies
Build: xz
2016
April May June
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 7 1 2 3 4
3 4 5 6 7 8 9 8 9 10<11>12 13 14 5 6 7 8 9 10 11
10 11 12 13 14 15 16 15 16 17 18 19 20 21 12 13 14 15 16 17 18
17 18 19 20 21 22 23 22 23 24 25 26 27 28 19 20 21 22 23 24 25
24 25 26 27 28 29 30 29 30 31 26 27 28 29 30The program produced TeX output so I could print a nice wall calendar (complete with tasks and birthdays).
Was kind of klunky, but it worked.
Try:
cal -m
I even have it aliased to "calm" :-) cal: option requires an argument -- m
usage: cal [-jy] [[month] year]
cal [-j] [-m month] [year]
ncal [-Jjpwy] [-s country_code] [[month] year]
ncal [-Jeo] [year]No, I feel that Sunday is the day of rest I start my week with, then I do some work, and finally I rest again: in that way my day is a microcosm of my week (and one might think that in a more primitive society my year would be a macrocosm, as I did more work spring-summer than during the winter).
I personally detest calendars which display Monday as the first day of the week, and am genuinely curious why ISO chose that.
Solomon Grundy,
Born on a Monday,
Christened on Tuesday,
Married on Wednesday,
Took ill on Thursday,
Grew worse on Friday,
Died on Saturday,
Buried on Sunday,
That was the end,
Of Solomon Grundy.
Also, Saturday and Sunday are the weekend, not the week-edges.--
There's a bug in cal -- the man page says "-M" makes the week start on Monday, but my version doesn't accepthe argument.
I find it quite confusing when calendars mess this up. I once booked a flight on the wrong day, because I somehow switched to the American localization of the airline's website part-way through the booking process.
I think ISO chose it because there was considerable difference between countries as to what the first day of the week in usual calendar presentation was when ISO 8601 was being considered, they needed something consistent, and it just happened to shake out to Monday.
Because ISO is all about business, and Monday is the start of the business/banking etc week.
ncal -M [year] clear
cal
echo "Hey \033[1m$USER\033[0m it's \033[1m`date '+%A %d %B @ %T'`\033[0m" |
tr '[A-Z]' '[a-z]'
echo "logins:\c" ; who | wc -l
df -hEnclose the lot in { .... } >&2
to send output to stderr instead.
Or only output if the session is interactive, with isatty or if PS1 is set or $- contains 'i'.
I call a shell script from my .bashrc so does this have the same effect? I'll take this advice and wrap the script. I don't use scp or rsync but possible could at some time, thanks @emmelaich.
https://en.wikipedia.org/wiki/Util-linux
read all the pages, explore all the man pages, then experiment and learn.
or go to the source: https://github.com/karelzak/util-linux