how to Sort a coma separated file (with following details) based on salary (ascending or descending) a.Ename,firstname,lastname,salary

link|improve this question
feedback

2 Answers

sort -t, -k4,4 filename

That's for ascending, throw in -r for descending.

link|improve this answer
1  
Probably going to want -n to make the sort numeric, and hopefully you salary numbers don't have commas in them :-) If so, you should paste a few example lines (with names/numbers changed a little to protect the innocent. – Kyle Brandt Dec 9 '09 at 12:51
feedback

In my country the separator is not , but ; - so the solution is more complicated. Just in case this applies here too...:

LC_ALL=C 
export LC_ALL

and instead of -t, I use

--field-separator=\;
link|improve this answer
feedback

Your Answer

 
or
required, but never shown