Unix/Linux — find & xargs — Spaces in filenames

by

Spaces in filenames can be a problem when using find | xargs combination.

To solve this, use:

find . -print0 | xargs -0 <command>

This tells find and xargs to use the ASCII NUL character instead of space to end (separate) the filenames.

Advertisements

5 Responses to “Unix/Linux — find & xargs — Spaces in filenames”

  1. ivanatora Says:

    Nice tip 🙂
    Nice blog, too.
    I’d recommend to split the C/C++ categories, becouse lots of your snipplets are valid in only one of the two languages.

  2. Todd Trimmer Says:

    Sweet!

  3. Cal Leeming Says:

    Thank you very much for the xargs/find fix for spaces in file names – just saved me hours of man page searching 🙂

  4. Edu Rodríguez (@sourcerebels) Says:

    Why don’t use this?

    find . | xargs -d “\n” command

    I think works in the same manner and its easier to remember.

  5. online resume writer free Says:

    online resume writer free

    Unix/Linux – find & xargs – Spaces in filenames | Not So Frequently Asked Questions

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: