Skip to content
Vidar Holen edited this page Oct 4, 2015 · 7 revisions

Use -print0/-0 or find -exec + to allow for non-alphanumeric filenames.

Problematic code:

find . -type f | xargs md5sum

Correct code:

find . -type f -print0 | xargs -0 md5sum

Rationale:

By default, xargs interprets spaces and quotes in an unsafe and unexpected way. Whenever it's used, it should be used with -0 or --null to split on \0 bytes, and find should be made to output \0 separated filenames.

Exceptions

None.

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature above to find a specific one, or see Checks.

Clone this wiki locally