Re: How to have a starting directory with a specific...

Bernhard Voelker <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <[email protected]>
On 12/18/20 3:45 PM, Budi wrote:
> How to have a starting directory with a specification, e.g. it must be
> case insensitive ?

As you didn't provide an example, I'm not 100% sure what you mean.
What I _think_ you mean:

There are several directories in which you want to search like:

dir-a
dir-B
dir-c
dir-C
dir-D

Basically 'find' only process the starting points specified literally.
So to search in all of them, one has to call:

  find dir-a dir-B dir-c dir-C dir-D -print

But you can use the shell to do the matching.

  find dir-? -print

Now, let's assume you only want a certain subset of the above directories,
then you could use a more fine-grained pattern.

  find dir-[acBC] -print

Finally, for the very elaborate case, one could even use find/xargs to feed
another find process with the starting arguments.

  # based on the above dirs ...
  $ touch dir-c/file-empty
  $ uptime > dir-C/file-nonempty
  $ find -maxdepth 1 -mindepth 1 -type d -iname 'dir-c' -print0 \
      | xargs -0 --replace=__ARGS__ \
          find __ARGS__ -type f -size +1c -exec ls -ldog '{}' +
  -rw-r--r-- 1 70 Dec 18 19:10 ./dir-C/file-nonempty

Hope this helps.

Have a nice day,
Berny
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.