[ale] Recursive script help

Glenn C. Lasher Jr. glasher at nycap.rr.com
Fri May 3 15:03:23 EDT 2002



find . -name \*.xyz -type f -exec rm -f {} \;

It works like this:

the . says "start from here"  You can substitute any directory for the .

-name \*.xyz pattern-matches.  Be sure to either escape the * and ? chars
in your pattern, or to put the pattern inside of double quotes.

-type f means "Don't do this to directlries" by specifying regular files
(f).  You can say "only do this to directories" by specifying type d.
That's not a perfectly preciese description, but it should be good enough
for now.  See the man page for more detail.

-exec . . . \; means "do this."  You need to have a space before the "\;"

the rm -f {} falls into the -exec . . . \; clause.  The curly braces tell
find to substitute the file it has found there.

Hope this helps.

On Fri, 3 May 2002, Gary MacKay wrote:

> Is there a command that will delete all files, such as *.xyz or
> whatever,  in the current directory and all subdirectories below it?
>
> I can make a script with a "for" loop to get the current and one layer
> down, but how do I keep going to _all_ subdirs of subdirs of...? Is
> there a single command or is a script required?
>
>
> - Gary
>
> ---
> This message has been sent through the ALE general discussion list.
> See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
> sent to listmaster at ale dot org.
>

glasher at nycap.rr.com
You've been programmed by the Illuminati not to see the word "".


---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list