sorting numerically by first row

后端 未结 3 673
一整个雨季
一整个雨季 2021-01-26 13:22

I have a file with almost 900 lines in excel that I\'ve saved as a tab deliminated .txt file. I\'d like to sort the text file by the numbers given in the first column (they rang

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-26 13:50

    As stated here you can have problems with this (and in the other pseudo-follow-up-duplicate question you asked, yes, you did)

    tr '\r' '\n' < myfile.txt | sort -n
    

    It works fine here on MSYS but on some platforms you may have to add:

    export LC_CTYPE=C
    

    or tr will consider the file as a text file, and probably will tag it as corrupt after having reached the max line limit.

    Obviously I could not test it, but I'm confident it will solve the problem given what I read on the linked answer.

提交回复
热议问题