[Discuss] sort by value of last field in a line
David Bronaugh
dbronaugh at linuxboxen.org
Fri Nov 23 12:17:50 PST 2007
Xavier Mossman wrote:
> hmm this doesn't seem to work for me. multiline file with variable no.
> of space seperated fields per line. need to sort lines on the value of
> the last field in a line. output needs to show all fields for each
> line. getting rid of dups in last field would be so nice
> sort won't let you specify sort on last field when you don't know how
> many fields per line. gawk isn't so friendly for sorting by field
> value - end up trying to sort a multi-dim array so yu can preserve the
> original index - then still need to sort the original array.
> anyone wanna show me up on this? don't care whats used as long as its
> standard shell stuff
>
> tx Xav
OK, this caught my eye as being kind of a funny problem.
Anyhow, here's one solution (if all you care about is clustering of
filenames and errors):
cat file | rev | sort | rev
I thought it was amusing. Maybe others will too.
David
More information about the Discuss
mailing list