linux - Bash: Is it ok to use same input file as output of a piped command? -


Consider something like this:

  cat file | Order & gt; File  

Is this a good practice? Can this input file overwrite the same time as we are reading it, or does it always read in the first memory, then it is piped in the second command?

Obviously I can use temp files as an intermediate step, I'm just thinking ..

  T = $ (mktemp) cat file | Order & gt; $ {T} & amp; MV $ {t} file  

No, that's not okay. Perform all orders in a pipeline at the same time, and prepare the redirection before executing the shell command. Therefore, it is possible that the cat will overwrite the command file before being taught the file.

You need more than that.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -