My code below is supposed to find which company had the most business and then print the appropriate fields from another file which are the companies ID number and name. I can loop through awk and display all the total amount of business for each company but I need help in only printing out the total, Id, and name for the company with the highest sales amount. Plus, I am having problems only displaying the carrier id and name of each company but my script displays every carrier ID and company name.
#!/usr/bin/csh
set num = 1
set count = 5
while ($num <= $count)
awk 'BEGIN{count ='$num'}{if($2 == count) {x+=$5}} END{print x}' ShippingOrders.
tab
awk 'BEGIN{count = '$num'}{if($1 == count}{print $1,$2,$3}' Shippers.tab
@ num = $num + 1
end