Referring to this answer of mine which I used the same tmp file for the input to the process-substitution and also writing the output to the same tmp file in parent shell, does this will cause any interruption when reading in process-substitution and writing by the shell?
based on discussion in the comments and a similar post I found, seems that should not be conflict, right?
grep -xvFf <(cut -d'/' -f1 tmp) ext >> tmp
Related discussions in comments:
This looks very elegant, but isn't
tmpis being read and written to at the same time? – Quasimodo@Quasímodo no, child-shell opens the
tmpfor reading only and redirection is done aftergrepdone the processioning thought and shell open thetmpagain for writing (But still I'm not expert on this to 100% confirm that) – αғsнιη@Quasímodo
strace grep …shows that it opens by grep and close after finish, and so after grep done shell write the output totmp, so that will not interrupt at the same time – αғsнιη
grepwill first read the whole patterns file, then parse the other file. So before writing any output, it has finished reading the patterns. No recycling of lines will happen. So it will append the output, I guess that even this would work as expected:grep -f tmp ext >> tmp. – thanasisp Nov 15 '20 at 23:10moreutilspackage and usesponge. Basically, you'd replace the>> tmpwithsponge -a tmp– Nov 19 '20 at 07:39