Re: A question about the date Function
Thanks to those who answered my question. I have discovered in the process one big difference between the date function in freebsd and Linux. Under freebsd, date -r 1234567890 or whatever value you need converts that unsigned long in to the normal date output set to that reference value. IN Linux, -r should be followed by a file name and it gives you the formatted date as read from the mtime of that reference file. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: A question about the date Function
Martin McCormick mar...@dc.cis.okstate.edu writes: Thanks to those who answered my question. I have discovered in the process one big difference between the date function in freebsd and Linux. Under freebsd, date -r 1234567890 or whatever value you need converts that unsigned long in to the normal date output set to that reference value. IN Linux, -r should be followed by a file name and it gives you the formatted date as read from the mtime of that reference file. The *only* standardized option for date is -u... -- Lowell Gilbert, embedded/networking software engineer, Boston area http://be-well.ilk.org/~lowell/ ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
A question about the date Function
The man page on date has an example showing how to get an output showing the number of seconds since the Epoch. date -j -f %a %b %d %T %Z %Y `date` +%s There is an envokation of date embedded in this command of date +%s I was curious as to what this command does so I tried the long form and then the short form with: date -j -f %a %b %d %T %Z %Y `date` +%s f0 date +%s f1 I then compared the outputs of f0 and f1 and they are identical. What does the long form of this command give us that date +%s fails to do? Nothing is broken, here. I am just curious. Thank you. Martin McCormick WB5AGZ Stillwater, OK Systems Engineer OSU Information Technology Department Telecommunications Services Group ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: A question about the date Function
On Wed, 16 Sep 2009 15:25:04 -0500 Martin McCormick mar...@dc.cis.okstate.edu wrote: date -j -f %a %b %d %T %Z %Y `date` +%s f0 date +%s f1 I then compared the outputs of f0 and f1 and they are identical. What does the long form of this command give us that date +%s fails to do? Nothing is broken, here. I am just curious. Thank you. I suspect that the the long form is just an example designed to demonstrate more than one thing in single line rather than a practical suggestion. I used to use it in scripts and never questioned it until for some reason it stopped working, and I tried the simpler alternative. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: A question about the date Function
Martin McCormick wrote: date -j -f %a %b %d %T %Z %Y `date` +%s f0 date +%s f1 What does the long form of this command give us that date +%s fails to do? It's a contrived example: date -j -f %a %b %d %T %Z %Y `date` +%s -j says don't alter the system date -- this is used if you want to read and format a date/time string other than the present time. -f says use the following format to read the input date. That's %a -- abbreviated weekday name (localized) %b -- abbreviated month name (localized) %d -- day of month as decimal number, zero padded to two digits %T -- equivalent to %H:%M:%S %H -- Hour in 24h clock, zero padded to two digits %M -- Minute, zero padded %S -- Second, zero padded %Z -- Time zone name %Y -- Year as 4 digits including century. (See strftime(3)) Which looks like this: % date +%a %b %d %T %Z %Y Thu Sep 17 06:31:15 BST 2009 and that just happens to be the default *output* format date produces without any arguments. Which is appropriate as the next item on the command line is `date` Rune the date command without arguments and substitute the output into the command line here as a single argument +%s finally, says output the date that was read in as the number of seconds since the epoch. This is an argument to the initial date command. so the end result is that the command reads the current date time in the standard output format, parses all of that then converts it into seconds-since-the-epoch, using two invocations of the date(1) program to do so. Which is not at all efficient if all you need to do is generate the current epoch time. Just use date +%s for that. On the other hand, it does show you how to convert an arbitrary date/time to epoch time. eg.: % date -j -f %a %b %d %T %Z %Y Fri Feb 13 23:31:30 GMT 2009 +%s 1234567890 Cheers, Matthew -- Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW signature.asc Description: OpenPGP digital signature