There are many command in linux. I certainly do not know them all. There are two amusing and useful commands you should know about before we quit. One is date, which prints the current date and time to the command line and is useful for time stamping files. Once you know more about scripting, you include a line like:
% date
and the date and time will be printed to whatever file is collecting your output. date has many formatting options for its output. See the man pages for all the options. For example, to display the Julian date (day of the year, switch j) issue:
% date +%j
Note the plus (+) sign and the percent (%) sign.
Text can be included in the output by enclosing the text and the switch(es) in single quotation marks. The plus sign(+) must be the first character quoted. For example, to display the seconds since 1 January 1970, issue:
% date '+The number of seconds since New Years, 1970 is %s'
See if you can include text and multiple switches together in the same output.
A related command is ddate. This seems to just be nerd humor:
% ddate
That was not the second command I was talking about. What I was intending is the calendar command cal which will produce a Gregorian calendar for whatever year you specify, even for years that did not use the Julian calendar. For example,
% cal 1776
will tell you the day of the week for the American Independence Day. If you just wanted to see the month of July you could just issue:
% cal 7 1776
and see that Thursday was a big day that month.
Now for a little fun with cal. See if you can determine the rule for determining which years are leap years. You may think, as I once did, that any year evenly divisible by 4 is a leap year. You would be in error. That rule is close but there are some important modifications. Here are some hints:
% cal 2 1900
% cal 2 1984
% cal 2 2000
% cal 2 2500
Also, the year 1700 is anomalous. Good luck!!
If you made it this far, and retained a decent amount, you are a mighty penguin. There are many linux online resources on internet. Have fun.
Command | Meaning |
---|---|
date | display date and time |
date +%d | display current day of month-01 to 31 |
cal 1905 | display 12 month calendar for 1905 |
cal 3 1882 | display birth month of mathematician emmy noether |