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

debian - Kali Linux - Debootstrap error Failed to determine codename for the release - Super User

crash - Windows Rundll32 (child process of DllHost) is crashing. How can I even identify it? - Super User

Windows XP installation, no previous version of Windows NT - Super User