Quote:
Originally Posted by konsolebox
this command doesn't reset the time right?:
Code:
date +%a -d $1-$2-$3
. i haven't seen that
|
No. The -d option just means "use a date/time defined in the argument to this parameter", and the +%a just specifies that the output format is using the %a format string (week day). $1 $2 and $3 are the values of the first three arguments to the function - called the "positional parameters" in shell talk. I wrote the function to expect the year, month and day, so putting them together with hyphens between makes a date which the date program can understand, e.g. if the positional parameters are 2007, 02, and 12, the string passed to the date command would be "2007-02-12".
The date command
can be used to set the system date, but only if you use the -s (or --set) option, and have sufficient privileges to do it (i.e. you are root).
You should read the date manual page (enter terminal, type "man date"). Manual pages look a little confusing at first, but they all follow more or less the same format, and once you have a little experience reading them, you will be able to answer this sort of question for ourself with ease, and a lot more quickly than by asking others.
To my mind, the really nice thing about manual pages is that they are arranged like a tabloid news story. The first line tries to encapsulate the general gist of the page (i.e. a one line summary of that the subject of the page is), then there's a short overview description and so o, getting more and more detailed towards the end of the page.
Most manual pages have the same main sections, which are printed in CAPTIALS at the start of a line. If your manual browser is set up as most are, using less as a pager, you can search for a section, like OPTIONS easily, just by hitting / and then typing
.
The ^ means "start of line" in less searches.