Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Thank you for this, do you know how I can apply this to a large file, I have 16945 lines with more columns than just the chromosome column - sorry I've only amended my question to detail this now Commented Mar 12, 2020 at 18:19
  • it is still not clear what you need. I showed only approach, if you want to have file lines sorted numerically ascending based on numbers in first column, you only need to cat file1|sort -n > file2. It may help to understand you better, if you provide with 1) input file1 containing 4-5 lines ordered incorrectly; 2) desired properly ordered result file2, you want to get from file1. Commented Mar 12, 2020 at 18:32
  • Sorry about that, I've tried to re-do my example data for more clarity. I've also tried the line you provide in this comment but it gives an empty file Commented Mar 12, 2020 at 18:40
  • When I run just sort -n file1 I see it working, but then I add the > file2 file2 is empty Commented Mar 13, 2020 at 10:21