text processing - How to use sort on an awk print command? - Ask Ubuntu


i have couple of commands in awk script i'm writing:

print "here players , numbers, sorted last name" if(sum[x] > 500) {print x, $2} 

which outputs:

here players , numbers, sorted last name lebron james 23 kevin durant 35 kobe bryant 24 blake griffin 32 dikembe mutumbo 55 

how can use sort command in awk script sort players , numbers only?

you can add | sort -k2 command. sort alphabetically based on second column.

example:

$ echo "lebron james 23 kevin durant 35 kobe bryant 24 blake griffin 32 dikembe mutumbo 55" | sort -k2 

results in

kobe bryant 24 kevin durant 35 blake griffin 32 lebron james 23 dikembe mutumbo 55 

Comments

Popular posts from this blog

nvidia - NV18 [GeForce4 MX 4000] driver - Ask Ubuntu

drivers - No wi-fi network after install - Ask Ubuntu