I\'ve got a script that calls grep to process a text file. Currently I am doing something like this.
$ grep \'SomeRegEx\' myfile.txt > myfile.txt.temp $ m
sponge (in moreutils package in Debian/Ubuntu) reads input till EOF and writes it into file, so you can grep file and write it back to itself.
moreutils
Like this:
grep 'pattern' file | sponge file