From owner-freebsd-questions@freebsd.org Sat Aug 17 19:38:07 2019 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9999ECF2BA for ; Sat, 17 Aug 2019 19:38:07 +0000 (UTC) (envelope-from non.euc.geo.1854@gmail.com) Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) (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 469r7x5TKgz4fwQ for ; Sat, 17 Aug 2019 19:38:05 +0000 (UTC) (envelope-from non.euc.geo.1854@gmail.com) Received: by mail-pf1-x431.google.com with SMTP id q139so4827079pfc.13 for ; Sat, 17 Aug 2019 12:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:disposition-notification-to :date:user-agent:mime-version:in-reply-to:content-language; bh=W6f9EaGUtb95jYQ21smX3rt365w8ErlBO/U9HtC+i+E=; b=fh5RSG8LpQe5LIGv/wC7cKZAXGqkhP5h3jT17Fj11aGMRJEUYxTL1LkD4XKZH2XvUC Azq8THErs9Htoa/1H1rFwIOqZkVZMSwLc2ROJLPcEAz+7m3FD90mzLROwjy+3XIsbuF1 4t8s7MkxIHYsg4CuvPICY4Xsko324yIW7vqs5gEEqHc8v7ynofFxB2ZcbbIznK+pQFfT LW7ufWR64Anrqb5kRkh/wc4FCvgrOGJKQ1SXQDRa6MB1qDhvO6qC5VSJ3fE2a/sapC2D jMsSZr6kZ9PtHmXukWtKoq/dpfPq7XxkJ616CjJbcjAOuCHh9LEq0yy9uRMR1U7U7/P7 adRg== 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 :disposition-notification-to:date:user-agent:mime-version :in-reply-to:content-language; bh=W6f9EaGUtb95jYQ21smX3rt365w8ErlBO/U9HtC+i+E=; b=rMTXl6cOMcmuAAaiF7ppIpiZpzdF04KlkxwA8DAgScq8QJJBFV1810hS47QA+VlxsO JRJCGaRgRW6a0+VjMgYwbP+BprqEcuEgMk8T5vQjJ9M4/mNBNZvMuNQZ0VOrkaTN3zO4 d88EkxvCakTKUihA0IEo/GKDmLdoO5I3y9iRRBnyo6WBNtqostPgJLI1n6QRulfbSfzJ xNJq65CGma7NjDXkPY9FLRWmtqGJbRo5UoOBoFxWFqt4fNCflasWfd9/BefkVrTTcEnE Nf+HBscZZvi4AhuLO81RF42ny3YJH1kw0piU3iAxWgkwmAWF17fs6TpDRFCoxuSoLLU8 ORRg== X-Gm-Message-State: APjAAAXBrG+SqPGtwhXpJN/5KqeuOqeX2WUV2ZzoPsh5u5sDyxojqoI/ oaPEwfG30yIb0JwjRWxr8WdJckMR X-Google-Smtp-Source: APXvYqzlohyIuiwcqOcKt2AdSNejfCmy4MyTA1oA0VIzgHsm+T/HoOaA5HJWI4SdcXl/v4feURGiUQ== X-Received: by 2002:a17:90a:d146:: with SMTP id t6mr13406446pjw.76.1566070683989; Sat, 17 Aug 2019 12:38:03 -0700 (PDT) Received: from bsdpc.home.net (cpe-76-90-238-16.socal.res.rr.com. [76.90.238.16]) by smtp.googlemail.com with ESMTPSA id p10sm11400970pff.132.2019.08.17.12.38.03 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 17 Aug 2019 12:38:03 -0700 (PDT) Subject: Re: pkg query timestamp format To: freebsd-questions@freebsd.org References: From: "J.B." Message-ID: <34e81f2a-83c5-6de8-a220-42aa9b9f1e7a@gmail.com> Date: Sat, 17 Aug 2019 12:38:02 -0700 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Rspamd-Queue-Id: 469r7x5TKgz4fwQ X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=fh5RSG8L; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of noneucgeo1854@gmail.com designates 2607:f8b0:4864:20::431 as permitted sender) smtp.mailfrom=noneucgeo1854@gmail.com X-Spamd-Result: default: False [-2.00 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; FREEMAIL_FROM(0.00)[gmail.com]; TO_DN_NONE(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; NEURAL_HAM_SHORT(-1.00)[-0.997,0]; RECEIVED_SPAMHAUS_PBL(0.00)[16.238.90.76.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.10]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; TAGGED_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]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; HEADER_FORGED_MDN(2.00)[]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE_FREEMAIL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; IP_SCORE(0.00)[ip: (-9.12), ipnet: 2607:f8b0::/32(-2.95), asn: 15169(-2.38), country: US(-0.05)]; RCVD_IN_DNSWL_NONE(0.00)[1.3.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; RCVD_TLS_ALL(0.00)[] Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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, 17 Aug 2019 19:38:07 -0000 On 7/13/19 5:00 AM, freebsd-questions-request@freebsd.org 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...:-) Here's a modified version of your solution in awk: # pkg query %n/%t | awk '{ print $1 } { system("date -j -f \"%s\" " $NF " \"+%Y-%m-%d_%H:%M:%S\"") }' FS=\/ ORS=\\t xterm   2019-08-16_10:32:13 xvid    2018-12-25_00:19:03 xvinfo  2019-04-20_12:29:07