bug-findutils
[Top][All Lists]
Advanced

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

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


From: Bernhard Voelker
Subject: Re: How to have a starting directory with a specific...
Date: Fri, 18 Dec 2020 19:13:58 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]