How to remove duplicates from a file and write to the same file?

前端 未结 5 2143
花落未央
花落未央 2021-02-20 16:58

I know my title is not much self-explanatory but let me try to explain it here.

I have a file name test.txt which has some duplicate lines. Now, what I want

5条回答
  •  情话喂你
    2021-02-20 17:22

    You can use vim for editing file in-place:

    $ ex -s +'%!sort' -cxa test.txt
    

    Multiple files:

    $ ex -s +'bufdo!%!sort' -cxa *.*
    

提交回复
热议问题