[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How could you load only once a Linux ultility without a batch --input-files kind of option and repeatedly use it on many files? . . .



On Fri, May 15, 2020 at 12:41:07PM +0200, Albretch Mueller wrote:
>  What documentation, books, videos, ... would you suggest for me to
> read up if I were to investigate what exactly is "find" 's magic to
> hook other processes and keep a running instance for multiple "found"
> files?

You're overthinking this.  find(1) does NOT communicate with a coproc.
It launches multiple instances of the desired command as needed to work
around the fact that there is a finite limit on the number of arguments
that it can pass to each instance of the desired command.

<https://mywiki.wooledge.org/UsingFind> might be of some help here, but
if you've already refused to read the man pages, I'm not sure how much
benefit there is in offering you additional reading material.

Unix is not taught in "videos".  This isn't freaking Microsoft here.
Unix and its toolset are built around TEXT.

Books are a legitimate request, but I don't know of any great Unix books
at the moment.  Most of the books that include any kind of Unix shell
tools or scripting have massive flaws and are to be avoided.

Compare and contrast these commands:

 find . -type f -exec ls -l {} \;

 find . -type f -exec ls -l {} +

How do they differ?

The first one issues one "ls -l" command for each file found.

The second one gathers up multiple filenames into a list, and when it
thinks the list is the right size, it issues one "ls -l" command with
that entire list as arguments.  Then it repeats, until all the filenames
have been handled.

If you want to write your own tool set that launches a coprocess and
communicates the list of files to it over a socket (or whatever),
you're free to do that.  For most of the world, however, the standard
find(1) with -exec + is good enough.


Reply to: