Date: Tue, 11 Apr 2017 17:18:47 -0400 From: Anton Yuzhaninov <citrin+bsd@citrin.ru> To: freebsd-questions@freebsd.org Subject: Re: awk, swap elements A and B, pipe a command in place of an element Message-ID: <ed91685e-18ae-c69d-0b08-03107110a035@citrin.ru> In-Reply-To: <CAJ5UdcNWej7jSjMTdZf6Rmf9-EiUBroU3HzN-1EiGZx=JSB2Vw@mail.gmail.com> References: <CAJ5UdcNWej7jSjMTdZf6Rmf9-EiUBroU3HzN-1EiGZx=JSB2Vw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ed91685e-18ae-c69d-0b08-03107110a035>