Why piping to the same file doesn't work on some platforms?

后端 未结 5 1626
谎友^
谎友^ 2020-12-20 22:22

In cygwin, the following code works fine

$ cat junk
bat
bat
bat

$ cat junk | sort -k1,1 |tr \'b\' \'z\' > junk

$ cat junk
zat
zat
zat

5条回答
  •  Happy的楠姐
    2020-12-20 22:58

    You want to edit that file, you can just use the editor.

    ex junk << EOF
    %!(sort -k1,1 |tr 'b' 'z')
    x
    EOF
    

提交回复
热议问题