From: Jeff King Date: Fri, 24 Jun 2016 21:09:06 GMT Subject: Re: [PATCH v3 1/4] t5000: test tar files that overflow ustar headers Message-ID: <20160624210906.GD6282@sigill.intra.peff.net> In-Reply-To: On Fri, Jun 24, 2016 at 04:58:58PM -0400, Eric Sunshine wrote: > On Fri, Jun 24, 2016 at 3:07 PM, Jeff King wrote: > > On Fri, Jun 24, 2016 at 11:56:19AM -0700, Junio C Hamano wrote: > >> Jeff King writes: > >> > +tar_info () { > >> > + "$TAR" tvf "$1" | awk '{print $3 " " $4}' | cut -d- -f1 > >> > +} > > > >> Seeing an awk piped into cut always makes me want to suggest a > >> single sed/awk/perl invocation. > > > > I want the auto-splitting of awk, but then to auto-split the result > > using a different delimiter. Is there a not-painful way to do that in > > awk? > > The awk split() function is POSIX and accepts an optional separator argument. Thanks. I'm not that familiar with awk functions, simply because I came of age after perl existed, and using perl tends to be more portable and powerful (if you can assume it's available). But this is simple enough that it should be OK. Replacing it with: "$TAR" tvf "$1" | awk '{ split($4, date, "-") print $3 " " date[1] }' seems to work. -Peff