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

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User

sql server - "Configuration file does not exist", Event ID 274 - Super User