Skip to main content
2 of 2
added 17 characters in body
Stéphane Chazelas
  • 585.2k
  • 96
  • 1.1k
  • 1.7k

In most systems, there is a limit on the length of a commandline passed to any program, using xargs or -exec command {} +. From man find:

-exec command {} +
      This  variant  of the -exec action runs the specified command on
      the selected files, but the command line is built  by  appending
      each  selected file name at the end; the total number of invoca‐
      tions of the command will  be  much  less  than  the  number  of
      matched  files.   The command line is built in much the same way
      that xargs builds its command lines.  Only one instance of  `{}'
      is  allowed  within the command.  The command is executed in the
      starting directory.

Invocations will be much less, but not guaranteed to be one. What you should do is read the NUL separated filenames in the script from stdin, possible based on a commandline argument -o -. I would do something like:

$ find . -name something.txt -print0 | myscript -0 -o -

and implement the option arguments to myscript accordingly.

Timo
  • 6.5k
  • 1
  • 28
  • 30