pipe filenames to rm in unix
February 1st, 2007 by Lawrence David
say you’ve got a stream of filenames that you’d like to remove. for instance, i’ve got a bunch of filenames that pop out of this command:
grep -v “,” `search “boot0.txt”` | sed ’s/boot.*//’
turns out i can’t directly pipe this to rm. instead, i’ve got to use the xargs command, as so:
grep -v “,” `search “boot0.txt”` | sed ’s/boot.*//’ | xargs rm -r