Skip to main content
-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
Source Link
Stéphane Chazelas
  • 584.7k
  • 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 -0r0 -I mystr --max-args=1 find "path2" -name mystr -exec ls -lld {} \; +

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

Following hint by @muru to use -I in xargs, the working command is:

find "path1" -size 0 -printf "%f\0" | xargs -0 -I mystr --max-args=1 find "path2" -name mystr -exec ls -l {} \; 

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)

Source Link
Marisha
  • 373
  • 4
  • 15

Following hint by @muru to use -I in xargs, the working command is:

find "path1" -size 0 -printf "%f\0" | xargs -0 -I mystr --max-args=1 find "path2" -name mystr -exec ls -l {} \;