Skip to main content
2 of 2
-r needed to account for the case where the first find doesn't find anything. --maxargs redundant with -I. Missing `-d`. Better use `+` than `;` to avoid running one ls per file
Stéphane Chazelas
  • 584.8k
  • 96
  • 1.1k
  • 1.7k

Following hint by @muru to use -I in xargs, the working command (assuming GNU implementations of find and xargs) is:

find "path1" -size 0 -printf "%f\0" |
  xargs -r0 -I mystr find "path2" -name mystr -exec ls -ld {} +

(that assumes the names of the empty files don't contain wildcard characters as -name interprets its argument as a wildcard pattern)

Marisha
  • 373
  • 4
  • 15