From owner-freebsd-questions@freebsd.org Sun Jul 14 10:57:37 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 E751815DF3C6 for ; Sun, 14 Jul 2019 10:57:36 +0000 (UTC) (envelope-from andipersti@gmail.com) Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E2A306C706 for ; Sun, 14 Jul 2019 10:57:35 +0000 (UTC) (envelope-from andipersti@gmail.com) Received: by mail-wr1-x435.google.com with SMTP id c2so10925421wrm.8 for ; Sun, 14 Jul 2019 03:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=/yoZlDXWKl2LLqa70ADp86jNMn+15IPJWRlvxlUbSts=; b=J+rMnxvbzt7PZeS5e4qQsUDRJJ3FHXBZa4cfIjjbcyeBHyL0lWwpi29GMasEr/lnmi McaFR4ITeG6+UE9xXt2p1X/g92K6q3Xq/4ClDTQEmpeFlnrdekdOKZN7xThlTeW2EPld KL9fo/gGAsy8kZu9cGcgMo2QGLRepWtZIAS3t2vpUp9c8DnIyotgVaIKYDUeth0B2OTe /YY8TQACBFenwsq6DDqt0imdUPh/knxqSxaBUqnUYZSFCk8X7XzA4ZTzA+xP/BFgH464 gBIQdcr0mKPyYw2VjSiuyY6q2aNRAJAlEn4ZQrnY8diU3ijB5Fv6fW1xm/2l2slKfSRu 5RNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=/yoZlDXWKl2LLqa70ADp86jNMn+15IPJWRlvxlUbSts=; b=ckq7bJ9AQGkbtvxiogrKqesOBEiTIOO5PNBaDV4atM3JERnBmE6coj8mgl5LDHZX0E 4y4OEcN9546UsWAXU9gfKKinS6wCe8tK3piaVX1tTMjc1GMGwJLyU8clmB6ZpANOLkMy Xb2C8Vcb+F3d0o4zDuo6IIYEfpzLivi8lLH8AFG7nKyhDcOxeNpnn1fR3vgg4c9TZTKL xj4U1xoNHrcNKGf1dNjKiu2lx37ZabTV6Z+dMbgI+Povi8hKn8vxZEZT8+iImWD0MzNZ rEC2UJbH7AZwK/FcTtCJI9KnIPCFSx9vmRAaerAjKstpPeMmiYzI3cZnsZZ9ooUWvw57 QpZw== X-Gm-Message-State: APjAAAUMna4Obh2+KJGu1cLbAl1DnEMxYRuTIVYG+wwka3WuKLxfmpP0 Z1Ug2QyuXxXud0OVYyR9aQmUdjrc X-Google-Smtp-Source: APXvYqygCLLJfFXUHG+FwBT/O9ojohbiCyq39lv0ao2dy8FVtqZw2l3Rdcus/9gP4YDKlXVUVGQ0aA== X-Received: by 2002:adf:e843:: with SMTP id d3mr14217393wrn.249.1563101854064; Sun, 14 Jul 2019 03:57:34 -0700 (PDT) Received: from [192.168.178.20] (91-119-90-56.dsl.dynamic.surfer.at. [91.119.90.56]) by smtp.googlemail.com with ESMTPSA id c1sm27450655wrh.1.2019.07.14.03.57.33 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Sun, 14 Jul 2019 03:57:33 -0700 (PDT) Subject: Re: pkg query timestamp format To: freebsd-questions@freebsd.org References: <5D28CD7B.40102@webtent.org> <5343D197-AF3A-490E-AB75-F0624A77A3FE@kreme.com> From: Andreas Perstinger Message-ID: Date: Sun, 14 Jul 2019 12:57:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <5343D197-AF3A-490E-AB75-F0624A77A3FE@kreme.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US-large Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E2A306C706 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=J+rMnxvb; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of andipersti@gmail.com designates 2a00:1450:4864:20::435 as permitted sender) smtp.mailfrom=andipersti@gmail.com X-Spamd-Result: default: False [-6.60 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; FREEMAIL_FROM(0.00)[gmail.com]; TO_DN_NONE(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; NEURAL_HAM_SHORT(-0.62)[-0.619,0]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; MID_RHS_MATCH_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; IP_SCORE(-2.97)[ip: (-9.45), ipnet: 2a00:1450::/32(-2.89), asn: 15169(-2.44), country: US(-0.06)]; RCVD_IN_DNSWL_NONE(0.00)[5.3.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.5.4.1.0.0.a.2.list.dnswl.org : 127.0.5.0] 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 10:57:37 -0000 On 13.07.19 11:31, @lbutlr wrote: >> On 12 Jul 2019, at 18:30, David Christensen wrote: >> Here's a Perl one-liner: >> >> 2019-07-12 17:28:52 dpchrist@cvs ~ >> $ pkg query %n-%t | perl -ne '/(.+)-(\d+)$/; ($d,$m,$y)=(localtime $2)[3,4,5];$y+=1900; printf "%-50s %4i-%02i-%02i\n", $1, $y, $m ,$d' >> bash 2019-01-21 >> cvs 2019-01-21 >> gettext-runtime 2019-01-21 >> > > 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’t based on the date column. Not sure what it was based on. > > I also tried -k 2,4 and -k 2 -k 3 > > I assume I am missing something bloody obvious. TL;DR use sort -b -k 2 From man sort: "A field is defined as a maximal sequence of characters other than the field separator and record separator (newline by default). Initial blank spaces are included in the field unless -b has been specified; the first blank space of a sequence of blank spaces acts as the field separator and is included in the field (unless -t is specified). For example, all blank spaces at the beginning of a line are considered to be part of the first field." So you should notice that packages with short names are listed first because there are more blank spaces in front of the dates. Only when package names have the equal number of letters the dates get sorted as you expected. Bye, Andreas