Fastest way to sort files

Posted by Werner on Stack Overflow See other posts from Stack Overflow or by Werner
Published on 2010-03-16T13:17:13Z Indexed on 2010/03/16 13:26 UTC
Read the original article Hit count: 222

Filed under:
|

Hi,

I have a huge text file with lines like:

-568.563626  159   33  -1109.660591  -1231.295129  4.381508
-541.181308  159   28  -1019.279615  -1059.115975  4.632301
-535.370812  155   29  -1033.071786  -1152.907805  4.420473
-533.547101  157   28  -1046.218277  -1063.389677  4.423696

What I want is to sort the file, depending on the 5th column, so I would get

-568.563626  159   33  -1109.660591  -1231.295129  4.381508
-535.370812  155   29  -1033.071786  -1152.907805  4.420473
-533.547101  157   28  -1046.218277  -1063.389677  4.423696
-541.181308  159   28  -1019.279615  -1059.115975  4.632301

For this I use:

for i in file.txt ; do sort -k5n $i ; done

I wonder if this is the fastest or more efficient way

Thanks

© Stack Overflow or respective owner

Related posts about bash

Related posts about sorting