Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reduce script/calls

Status
Not open for further replies.

clemhoff

Technical User
Jul 10, 2007
19
FR
Hi all,

Just wondering if there's a way to write the following command in just one awk call:

#!/bin/sh
...
awk '{printf "%s" (NR%5 ? "\t" : "\n"),$0}' | awk 'BEGIN{OFS="\t"} {print "'"$1"'", "'"$2"'", $2, $1, $3, $4, $5, "'"`date +%d\/%m\/%Y\ %H:%M:%S`"'", ""}'
...

stdout=
27/07/07
92410
AnyText_1.
Blah_1
92410
16/07/07
92410
AnyText_2.
Blah_2
92410
16/07/07
92410
AnyText_3.
Blah_3
92410

Desired output= (tab delimited)
9756-R2 555 8N01076123426 92410 27/07/07 AnyText_1. Blah_1 92410 08/08/2007 12:35:23
9756-R2 555 8N01076123426 92410 16/07/07 AnyText_2. Blah_2 92410 08/08/2007 12:35:23
9756-R2 555 8N01076123426 92410 16/07/07 AnyText_3. Blah_3 92410 08/08/2007 12:35:23

Thank you
clem
OS X.4.10
 
Like this ?
Code:
awk "BEGIN{f1=\"$1\";f2=\"$2\";f8=\"`date +'%d/%m/%Y %H:%M:%S'`\"}"'
{f[NR%5]=$0;if(NR%5)next
 printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t\n",f1,f2,f[2],f[1],f[3],f[4],f[0],f8
}'

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yep PVH that works!

Thank you M'sieur
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top