From owner-freebsd-questions@freebsd.org Wed Apr 12 12:32:39 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 460D7D3A4F9 for ; Wed, 12 Apr 2017 12:32:39 +0000 (UTC) (envelope-from olivares14031@gmail.com) Received: from mail-ua0-x22d.google.com (mail-ua0-x22d.google.com [IPv6:2607:f8b0:400c:c08::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F3B0F39F for ; Wed, 12 Apr 2017 12:32:38 +0000 (UTC) (envelope-from olivares14031@gmail.com) Received: by mail-ua0-x22d.google.com with SMTP id 49so15110583uau.2 for ; Wed, 12 Apr 2017 05:32:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=iQQWIp58tbEHJ1J9yz6u/Xd6Ad9gPQcR0+j2EfBrh8c=; b=LWGtlgSqDRwbfayWRmkSZyyc5+qGQX57X1HetZvBS55zq9jvvxNlfIQcQHXQvFbJJB pX6g5AVDX6cF6IsCYd58Zi/Y9aWlp9P6ymYzIpHI5nORT1SFaWsW8xsHrz7uMyqINsrw KGCxp0+8uRb/xCQ3arnk81PUr6ZNNf2czRG9LgWqcl9MJnLELwgrEd5Y19YRvNucl/Su b2ZcbGyzpgU8zJ8iJ46NVwGgnxAsta6riTyA5eJ2vIyGKZNR5L/FXNt9wkI/6ca75I6T dSIp3Vz33n0IZ/86m0OJJ/rYijHNltfBhPbVEY72jtHUAYzyAndWTCFbnWU8ZuQTEnAu cP8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=iQQWIp58tbEHJ1J9yz6u/Xd6Ad9gPQcR0+j2EfBrh8c=; b=PHK6Ret7WO8asKdI9AJ9abIpMajJPJyLnNPRQsuIWCKStb0ziAHCUK1G2KpjG7PxM1 6sY9SoyI9LgRm07MzhoGpp8LajsoKCr8N0KZE5Abmcadpae1YuTiC45RXCVqh4DDT4Zw AuF1AC2uSQDwddh6GNN7h16YtCago/ZFmyDwAZ3cCkX97tOSa72lO0+ZYKIsMRERhMkh vZBBkRC3fRsjNmc6o5jkj4mOockIvHKth+fLHz9ytFDm5gMlNnqPajNumBr7fdAvaPVM 0RXT8G41BLFD/EFXO34PrWbUiZ+XiIEP34Mc82BvvQphheoGmLtA2tz4m+Setc4h8htk 1ZHQ== X-Gm-Message-State: AN3rC/6TTeGNnPJM9vHTlpu8Udaee+JlDYcoodVsB0wLD4P3xDRPyKAIx/XI8fVDDsTY9tzZcJoMgt54uFzthw== X-Received: by 10.176.91.8 with SMTP id u8mr1315629uae.150.1492000358057; Wed, 12 Apr 2017 05:32:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.159.34.131 with HTTP; Wed, 12 Apr 2017 05:32:37 -0700 (PDT) In-Reply-To: <20170411231407.GZ2787@mailboy.kipshouse.net> References: <20170411231407.GZ2787@mailboy.kipshouse.net> From: Antonio Olivares Date: Wed, 12 Apr 2017 07:32:37 -0500 Message-ID: Subject: Re: awk, swap elements A and B, pipe a command in place of an element To: Karl Young Cc: Anton Yuzhaninov , FreeBSD Questions Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Apr 2017 12:32:39 -0000 On Tue, Apr 11, 2017 at 6:14 PM, Karl Young wrote: > Anton Yuzhaninov(citrin+bsd@citrin.ru)@2017.04.11 17:18:47 -0400: >> On 04/11/17 16:19, Antonio Olivares wrote: >> > However if we have 3 elements, namely a >> > >> > TimeStamp Home Away >> > 1 2 3 >> > >> > We can swap 2 and 3 with above code. However I want to format $1 with >> > date -r "$i" "+%a %b %d %Y %I:%M %p" and then swap $2 and $3. With >> > regular BSD awk strftime command is not available. We can use for >> > command to format the timestamp >> >> echo "1491945088 x y" | awk '{ system("date -r "$1" \"+%a %b %d %Y %I:%M >> %p\" | tr -d \"\n\""); print " "$3" "$2}' >> Tue Apr 11 2017 05:11 PM y x >> > > Heh heh. Perl has no lock on TMTOWTDI > Thanks to both yourself and Anton for your suggestions. This works beautifully :) Best Regards, Antonio