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

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

software installation - How to install linux driver for a lb-link wireless usb adapter - Ask Ubuntu

permissions - Mount is denied because the NTFS volume is already exclusively opened - Ask Ubuntu