capser
capser

Reputation: 2635

date command read file info like stat

I found this is a script that seems to read in the date. It sort of works like the stat command. I had no idea date could do this. I have no idea how it works, and do not see the '-I' or '-r' flag in the man pages.

/bin/date -I -r /home/capser/casper_file.20180813.csv
2018-08-13

Can someone point me to the documentation.

Upvotes: 0

Views: 278

Answers (1)

Charles Duffy
Charles Duffy

Reputation: 295659

date is provided by your operating system; it is not part of bash itself, and which options it provides varies based on your OS: The local documentation provided by man date is canonical in terms of determining which options are available for the version of date you actually have installed.

With respect to documentation for the version of date the command you're quoting was written for, however -- those options are provided by GNU date; a copy of its man page is available at http://man7.org/linux/man-pages/man1/date.1.html, and reads in part as follows:

   -r, --reference=FILE
        display the last modification time of FILE

   -I[FMT], --iso-8601[=FMT]
          output date/time in ISO 8601 format.  FMT='date' for date only
          (the default), 'hours', 'minutes', 'seconds', or 'ns' for date
          and time to the indicated precision.  Example:
          2006-08-14T02:34:56-06:00

If you want to know how to find the modification time of a file on a non-GNU system, that's a different question -- for which BashFAQ #87 is likely to be helpful.

Upvotes: 1

Related Questions