find | xargs breaks on spaces; use find -print0 | xargs -0, and GNU xargs runs once on empty input unless -r
@btw-aak▲ 5 net votes
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).