From owner-freebsd-questions@freebsd.org Tue Apr 11 21:18:59 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 373BDD3AD13 for ; Tue, 11 Apr 2017 21:18:59 +0000 (UTC) (envelope-from citrin+bsd@citrin.ru) Received: from hz.citrin.ru (hz.citrin.ru [88.198.212.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F3C45325 for ; Tue, 11 Apr 2017 21:18:58 +0000 (UTC) (envelope-from citrin+bsd@citrin.ru) Received: from x220.lan (unknown [IPv6:2601:18a:c680:9888:3190:e4a6:d14:f3c8]) by hz.citrin.ru (Postfix) with ESMTPSA id 8BCA029A32A for ; Tue, 11 Apr 2017 21:18:49 +0000 (UTC) Subject: Re: awk, swap elements A and B, pipe a command in place of an element To: freebsd-questions@freebsd.org References: From: Anton Yuzhaninov Message-ID: Date: Tue, 11 Apr 2017 17:18:47 -0400 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrin.ru; s=s0; t=1491945529; bh=ouBRPFV+OndjoKKRkPZBom4Q4gceOay6tf7S7qcgLTY=; h=Subject:To:References:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=YhdOYp8jP/HWag4UDllJldTXTO8xmNLmfloecJELIGD9eHwEnr96KqmEgg2cbVOJ9U6dWMxRXA2NS3fxphsesC7DaNqokfJEaxcrpjaX64tNZtbsrxSWzA5sIKGpl0KwlVooPuCu5Kxd1uhdtKYGQobUCpiLA04he90Lwn4fUXU= 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: Tue, 11 Apr 2017 21:18:59 -0000 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