This question prompted a thought I was not sure I understood well. I know that it is not possible or correct to use pipelines like cat myfile | grep -v mypattern > myfile due to how file handles are set up. However, why can't we simply use cat myfile | grep -v mypattern| tee myfile>/dev/null to modify the file in place? Are there any simple examples where it fails?
Specifically, does it lead to corruption or is it more of not being inplace edit, but rather overwrite?
Updating the question, I would appreciate if the answers would consider this too:
Is there problems with using cat myfile | grep -v mypattern| bash -c 'rm myfile; cat > myfile'?
