:: Re: [DNG] Using find to find all oc…
Top Pagina
Delete this message
Reply to this message
Auteur: R A Montante, Ph.D.
Datum:  
Aan: dng
Onderwerp: Re: [DNG] Using find to find all occurences of a file(text string) in a tree.
You need one or more tests ("predicates") for which files you want.  I
typically use "-name" or "-iname", "-type", or occasionally "-regex". 
Some examples:

Find all filenames with a "~" tilde at the end (vim backup files):

*find /home/me/Documents  -iname  "*~"*

Discard all filenames with a "~" tilde at the end:

*find /home/me/Documents  -iname  "*~"  -exec rm {} \;*

Change permissions on everything that isn't a directory:

*find /home/me/Documents  ! -type d  -exec chmod -x {} \;*

Look for ".h" files in directory paths that include "include" somewhere :

*find /usr  -regex ".*include.*\.h" -ls*

The "-iname" predicate is just a case-insensitve version of "-name". 
The "!" operator reverses the sense of the following predicate.  The
"-exec" predicate lets me do what I want with anything that matches; it
must be terminated with the "*\;*" token.

(If my colors come through, then green is the root/starting-point, red
is your specific information.

-Bob



On 11/8/24 07:00, dng-request@??? wrote:
> Date: Fri, 8 Nov 2024 15:00:02 +1100
> From: terryc<terryc@???>
> To:dng@???
> Subject: [DNG] Using find to find all occurences of a file(text
>     string) in a tree.
> Message-ID:<20241108150002.68b04a4b@???>
> Content-Type: text/plain; charset=US-ASCII

>
> Hopefully just suffering brain fade here
> man find basically give
>
> find [starting point] [expression]
>
> is taken as two starting points.
>
> Example find /media/raid0/file /proc
> results in dumping everyfile under /media/raid0/file then /proc
>
> History. a quick and dirty backup system was set up to basically suck
> all the systems on the LAN without compression into/m/r/f/system/date/
> and that filesystem/hardware is getting very crowded and thoughts are
> to remove certain non-critical subdirectories or move the critical
> ones.
>
> T.I.A.
> terryc


--
R A Montante, Ph.D.
Department of Mathematics, Computer Science, and Digital Forensics
Commonwealth University - Bloomsburg University campus
--
The Tao of math: The numbers you can count are not the real numbers.