Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to sort a comma separated file (with following details) based on salary (ascending or descending)

share|improve this question

sort -t, -k4,4 filename

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

share|improve this answer
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

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

export LC_ALL

and instead of -t, I use

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.