Date: Fri, 12 Jul 2019 20:42:48 +0200 From: Polytropon <freebsd@edvax.de> To: Robert Fitzpatrick <robert@webtent.org> Cc: Robert Fitzpatrick via freebsd-questions <freebsd-questions@freebsd.org> Subject: Re: pkg query timestamp format Message-ID: <20190712204248.b79ccad6.freebsd@edvax.de> In-Reply-To: <5D28CD7B.40102@webtent.org> References: <5D28CD7B.40102@webtent.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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... :-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20190712204248.b79ccad6.freebsd>
