Home > OS >  A shell script: cat a.t xt> a.t xt
A shell script: cat a.t xt> a.t xt

Time:10-28

I found this in running a shell script: one more thing:
The cat a.t xt | sort & gt; A.t xt
The didn't like me to do a.t xt files in good order, and write again a.t xt, instead is empty in the a.t xt
I find this code, it is capable of achieving the goal:
The cat a.t xt | echo | sort & gt; A.t xt
I wonder why, but baidu, hope leaders help solve

CodePudding user response:

Sorry, the cat a.t xt | echo | sort if doesn't work

CodePudding user response:

Can't be the same file

CodePudding user response:

The shell when parsing the command to initialize the pipes, so & gt; A.t xt file first emptied, the cat at less than content at this time,
So to change the source file, cannot use pipes,
If the pipe, can use a temporary file transfer
  • Related