This is more of a challenge than anything: can it be done safely and elegantly in one line?
The main problem, both the patterns and the files are result of commands which may fail.
grep -Fxvf <(cmd-filter) <(cmd-list) | xargs -d "\n" gvfs-trash
- cmd-filter may return 0 to fail or output a bogus empty list if passed a bogus path (it's a knockoff remote ls).
- cmd-list is just a depth find. A failure here is not all bad, because even a typo just means the next, gvfs-trash program that will receive piped ouput, will not run on anything. It would be handy if a typo caused a failure though.
Obviously the main problem is the first. If it fails for any reason, or is empty because of a typo, all the files printed by cmd-list will be trashed. I'd like to avoid this, to say the least.
I've read on man that
grep -f is supposed to fail grep if cmd-filter is empty, but i haven't experienced this in the above. If i replace cmd-filter by
echo "" i get all the files in cmd-list. And what about failure from other reasons?
edit: thinking about this, this might because of the -v switch, which is necessary to invert the match to get the lines not in cmd-list. If so, i find it strange it finds the invert match of empty pattern list to be everything.
Anyway, since elegance may be impossible, and if there is no good response that is not 'just make a script you lazybones' i'd still mark correct a single line hack that uses tmp files or similar.
edit: I myself 'failed' this challenge and used a long script (ab)using vars and process substitution to make this. Turned out that i didn't need to check both error status and if the stdout was empty in cmd-filter too, because in all error cases i found it was empty too.