From owner-freebsd-questions@freebsd.org Sat Jul 13 00:35:31 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 AC77E15DB38A for ; Sat, 13 Jul 2019 00:35:31 +0000 (UTC) (envelope-from dpchrist@holgerdanske.com) Received: from holgerdanske.com (holgerdanske.com [IPv6:2001:470:0:19b::b869:801b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "xray.he.net", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 024A793CBE for ; Sat, 13 Jul 2019 00:35:30 +0000 (UTC) (envelope-from dpchrist@holgerdanske.com) Received: from 99.100.19.101 ([99.100.19.101]) by holgerdanske.com with ESMTPSA (ECDHE-RSA-AES128-GCM-SHA256:TLSv1.2:Kx=ECDH:Au=RSA:Enc=AESGCM(128):Mac=AEAD) (SMTP-AUTH username dpchrist@holgerdanske.com, mechanism PLAIN) for ; Fri, 12 Jul 2019 17:30:30 -0700 Subject: Re: pkg query timestamp format To: freebsd-questions@freebsd.org References: <5D28CD7B.40102@webtent.org> From: David Christensen Message-ID: Date: Fri, 12 Jul 2019 17:30:30 -0700 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: <5D28CD7B.40102@webtent.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Sat, 13 Jul 2019 00:35:31 -0000 On 7/12/19 11:12 AM, 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 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 David