Pipe results of locate into rm

If filenames contain spaces you should use

locate -0 $something | xargs -0 rm

From locate man page:

-0, --null Separate the entries on output using the ASCII NUL character instead of writing each entry on a separate line. This option is designed for interoperability with the --null option of GNU xargs(1).

or

locate $something | while read f; do rm "$f"; done

Also, you should protect *.orig with quotes, to avoid the shell expansion, and pass it to locate untouched.


It's xargs not xarg