Home > Software design >  Sort data by two columns in linux
Sort data by two columns in linux

Time:06-21

I have a file as shown in the image below and I would like to sort this by 2 columns (chr) and then by 3rd column (bpos) in Linux. Please suggest to me what is the best way to get this.

enter image description here

CodePudding user response:

sort can do it with:

sort  -k2,2n -k3,3n file.txt
  • -k2,2n sort by 2nd column, numerically
  • -k3,3n then sort by 3rd column, numerically
  • Related