I am reading through the GNU Core Utils manual and I am experimenting with the date command. Here is what I found in the text:
datecommand has a
- Parse each line in datefile as with -d and display the resulting date and time
- that means date is looking at each line in datefile and treating it as a date string for use to display that particular date.
In chapter 28 (Date input formats) it is stated:
The output of the date command is not always acceptable as a date string, not only because of the language problem, but also because there is no standard meaning for time zone items like ‘IST’. When using date to generate a date string intended to be parsed later, specify a date format that is independent of language and that does not use time zone items other than ‘UTC’ and ‘Z’. Here are some ways to do this:
$ LC_ALL=C TZ=UTC0 date
Mon Mar 1 00:21:42 UTC 2004
- this statement (especially the bold part) implies to me that I should be able to put in the datefile a date command such as the one above and the date command I issue in the terminal should be able to parse that date command in the datefile and output the corresponding date.
For some reason it is not working for me. Either there is something wrong with my date command in the datefile (wrong quotation marks, some special syntax which I am not aware of....), or the
-f datefile option is not capable of handling this situation.
What I am asking in summary is:
- can the date -f command be fed a file where the date string on one line is another date command? e.g. can I put in a file a string "date" on the first line (which as a command would return the system time), and then feed that file in a date -f command and get the current system time (generated by the date command in the file)?