So I'm deleting some files using find with regex's and then piping to xargs -0 rm or simply adding --delete
Occasionally, I need to exclude some of them from the removal - I write the find output to file, delete some lines and replace the new line characters with null characters. I do this in vim and now I have this EOF character that is causing me an annoyance, when I feed it to the remove command. Here's a very simplified test case using file instead of rm:
[testdir]$ touch t{1..3}
[testdir]$ find . -name 't*' -print0 > xa
[testdir]$ find . -name 't*' > xb
[testdir]$ cat -v xa
./t3^@./t2^@./t1^@[testdir]$ cat xb
./t3
./t2
./t1
[testdir]$ vim xb
In vim I do ':%s/\n/CTRL-@/' and save. Afterwards, the undesired effect, compared to the original find output file:
[testdir]$ cat -v xb
./t3^@./t2^@./t1^@
[testdir]$ xargs -a xa -0 file
./t3: empty
./t2: empty
./t1: empty
[testdir]$ xargs -a xb -0 -E '\012' file
xargs: warning: the -E option has no effect if -0 or -d is used.
./t3: empty
./t2: empty
./t1: empty
: cannot open `\012' (No such file or directory)
rm works fine with all the files, it's just that I get an error at the end. Notice how the original output doesn't insert new line at the end, see result from 'cat xa'. Also, xargs tells me that I cannot exclude that EOF character, because of the null delimeter.
I'd love to know to know how to fix this, any ideas?