Date: Sun, 14 Jul 2019 03:17:57 -0600 From: "@lbutlr" <kremels@kreme.com> To: freebsd-questions@freebsd.org Subject: Re: pkg query timestamp format Message-ID: <94704E03-AE5F-458A-89B5-F35D977452C3@kreme.com> In-Reply-To: <20190713202207.4e7f827e.freebsd@edvax.de> References: <5D28CD7B.40102@webtent.org> <e2771f34-b0fe-5c09-dc8b-b2d549fdacbf@holgerdanske.com> <5343D197-AF3A-490E-AB75-F0624A77A3FE@kreme.com> <20190713202207.4e7f827e.freebsd@edvax.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On 13 Jul 2019, at 12:22, Polytropon <freebsd@edvax.de> wrote: > On Sat, 13 Jul 2019 03:31:17 -0600, @lbutlr wrote: >> On 12 Jul 2019, at 18:30, David Christensen = <dpchrist@holgerdanske.com> wrote: >>> $ pkg query %n-%t | perl -ne '/(.+)-(\d+)$/; ($d,$m,$y)=3D(localtime = $2)[3,4,5];$y+=3D1900; printf "%-50s %4i-%02i-%02i\n", $1, $y, $m ,$d=E2=80= =99 >> I tried to add a | sort -k 2, thinking that would sort the output >> by date, but while it changed the order of the output (no other >> number did), it wasn=E2=80=99t based on the date column. Not sure = what >> it was based on. >>=20 >> I also tried -k 2,4 and -k 2 -k 3 >>=20 >> I assume I am missing something bloody obvious. >=20 > In the formatting rule of the perl printf command, put a > delimiter, for example "/": "%-50s/%4i-%02i-%02i\n", then > use "| sort -t '/' +1" or "| sort -g -t '/' +1". ISO dates > are sortable by definition. This should sort by the _2nd_ > column with the defined delimiter. Sure, but -k should pick up on white space, I thought. > Or, probably much easier, change the printf command to > create output as "<date> <package>" instead of the example > providing "<package> <date>", and just send this to "| sort=E2=80=9D. This is what I did, in fact, but I was (and am) confused why sort -k 2 = didn=E2=80=99t work on the original output. --=20 Some people are like a Slinky toy - not really good for anything, but you still can't help but smile when you shove them down the stairs.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?94704E03-AE5F-458A-89B5-F35D977452C3>