From owner-freebsd-questions@freebsd.org Sun Jul 14 09:18:00 2019 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B182415DD671 for ; Sun, 14 Jul 2019 09:18:00 +0000 (UTC) (envelope-from kremels@kreme.com) Received: from mail.covisp.net (mail.covisp.net [65.121.55.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B82BC68395 for ; Sun, 14 Jul 2019 09:17:59 +0000 (UTC) (envelope-from kremels@kreme.com) From: "@lbutlr" Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: pkg query timestamp format Date: Sun, 14 Jul 2019 03:17:57 -0600 References: <5D28CD7B.40102@webtent.org> <5343D197-AF3A-490E-AB75-F0624A77A3FE@kreme.com> <20190713202207.4e7f827e.freebsd@edvax.de> To: freebsd-questions@freebsd.org In-Reply-To: <20190713202207.4e7f827e.freebsd@edvax.de> Message-Id: <94704E03-AE5F-458A-89B5-F35D977452C3@kreme.com> X-Mailer: Apple Mail (2.3445.104.11) X-Rspamd-Queue-Id: B82BC68395 X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of kremels@kreme.com designates 65.121.55.42 as permitted sender) smtp.mailfrom=kremels@kreme.com X-Spamd-Result: default: False [-0.40 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.55)[-0.554,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; MISSING_MIME_VERSION(2.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; DMARC_NA(0.00)[kreme.com]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-0.91)[-0.914,0]; IP_SCORE(-0.26)[ip: (-0.90), ipnet: 65.112.0.0/12(-0.32), asn: 209(-0.01), country: US(-0.06)]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MX_GOOD(-0.01)[mail.covisp.net]; NEURAL_HAM_SHORT(-0.27)[-0.269,0]; RCVD_COUNT_ZERO(0.00)[0]; RCVD_IN_DNSWL_LOW(-0.10)[42.55.121.65.list.dnswl.org : 127.0.5.1]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:209, ipnet:65.112.0.0/12, country:US]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Jul 2019 09:18:00 -0000 On 13 Jul 2019, at 12:22, Polytropon wrote: > On Sat, 13 Jul 2019 03:31:17 -0600, @lbutlr wrote: >> On 12 Jul 2019, at 18:30, David Christensen = 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 " " instead of the example > providing " ", 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.