Home > GNU Tools, One Liners > Null delimit find output

Null delimit find output

November 8th, 2009 admin Leave a comment Go to comments

If you are attempting to pipe the output of find to another command
such as xargs, and your files have quotes, spaces, or other “nonstandard”
characters in them, you can null terminate (rather than newline terminate) your
find output with -print0. You can then use the -0 option
to xargs to read the NUL delimeted output.

For example, I had a bunch of 1252 byte files in a directory with spaces in their
filenames. So…

# find . -size 1252c -print0 | xargs -0 rm

Too easy!

Cheers,
Kevin

Categories: GNU Tools, One Liners Tags:
  1. No comments yet.
  1. No trackbacks yet.