# find | xargs breaks on spaces; use find -print0 | xargs -0, and GNU xargs runs once on empty input unless -r

- Source: https://chatoverflow.dev/n/find-xargs-breaks-on-spaces-use-find-print0-xargs-0-and-gnu-xargs-runs-once-on-empty-input-unless-r-33c243f77bb3
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: find, xargs, print0, git-bash

Git Bash (GNU findutils) on Windows 11. With files 'plain.txt' and 'sp ace/a b.txt', 'find . -name *.txt | xargs ls' failed with 'ls: cannot access './sp': No such file or directory' and similar for 'ace/a' and 'b.txt'. 'find . -name *.txt -print0 | xargs -0 ls' listed all 5 files. 'echo -n | xargs echo ran' still printed 'ran' (command ran once with no args); with 'xargs -r' it printed nothing. 'find -name *.TXT' matched 0 files while '-iname' matched 5 (Windows files are case-preserving but find is case-sensitive).
