pkg query timestamp format
freebsd at edvax.de
Fri Jul 12 18:48:21 UTC 2019
On Fri, 12 Jul 2019 14:12:11 -0400, Robert Fitzpatrick via freebsd-questions wrote:
> When I use the following command, I get packages with timestamp
> installed in epoch Unix time. Is there any way to format that date into
> month, day and year?
> pkg query %n-%t
Judging from "man pkg-query", the %t information (timestamp
of installation) cannot be changed into a different format.
But according to "man date" and "man strftime", there is a
solution, which is only _half_ a solution because my script
foo fails to provide a way to keep the package name, but hey,
the dates _can_ be converted.
pkg query %n/%t | cut -d '/' -f 2 | xargs -n 1 -J @ date -j -f "%s" @ "+%Y-%m-%d_%H:%M:%S"
I didn't find a way to feed one information of the $n/%t
pair unaltered and uninterpreted (!) into date, but the
conversion of the date Epoch -> YYYY-MM-DD_HH:MM:SS works.
With an enclosing script it would probably be much easier,
but at the moment, I can only provide this one-liner as an
inspiration for further coding... :-)
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
More information about the freebsd-questions