Quote:
Originally Posted by radoulov
Code:
awk 'NR == 1 { print "lead1 07q4 07q1 06q4 06q3 sept oct nov" }
$1 ~ "^("users")$" && NF > 1 {
x[$1]++
if (x[$1] == 1)
p[$1] = sprintf ("%s\t%s\t%s\t%s\t%s", $1, $2, $5, $6, $7)
if (x[$1] == 3) {
printf "%s\t%s\t%s\t%s\n", p[$1], $2, $3, $4
}
}' users="tim|tad" file
You can add more users in the pattern: tim|tad|pat etc.
Use nawk or /usr/xpg4/bin/awk on Solaris.
|
This works GREAT, I REALLY appreciate the help on this, but what if I wanted to sum up, columns 07q4 and 07q1, and then put that value at the end of the printf statement? Having issues with that part. Can you help?