Xargs choking on whitespace

Every once in a while the normal recursive bash command doesn’t work and I resort to using find with xargs. Of course xargs hates whitespace and I often find myself working with files created by others. xargs chokes on whitespace thinking it’s an indication of a new file. The solution is to get find to send null separated values instead of newline separated values, and get xargs to check for null characters instead of newlines. Both can be accomplished, find’s -print0 sends null values, xarg’s -0 will accept null values.

Here’s an example:
find ./website/ ! -perm -775 -print0 | xargs -0 chown production:wheel

via linuxdevcenter

No Comments

Post a Comment

Your email is never shared. Required fields are marked *