Why doesn't “sort file1 > file1” work?

前端 未结 7 1492
忘了有多久
忘了有多久 2020-12-03 21:23

When I am trying to sort a file and save the sorted output in itself, like this

sort file1 > file1;

the contents of the file1 is getting

7条回答
  •  攒了一身酷
    2020-12-03 22:03

    Bash open a new empty file when reads the pipe, and then calls to sort.

    In the second case, tee opens the file after sort has already read the contents.

提交回复
热议问题