Execute a command w/wildcards & recursive descent

Leslie Mikesell les at chinet.chi.il.us
Sun Sep 2 01:49:49 AEST 1990


In article <13204 at hydra.gatech.EDU> gt0178a at prism.gatech.EDU (BURNS,JIM) writes:
>Listed below is a 'C' program I wrote because I got tired of 'ls -R' and
>'find' not understanding wildcards, even if quoted. Can anyone tell me how
>to do something like

>find . -type d -exec 'general command with wildcards and {}' \;

Unless there is some requirement to do a single directory at a time you
could use:

find . -type f -name 'wildcard' -print | xargs command

xargs reads stdin for newline-delimited filenames and bundles them in
groups to pass on the command line to one or more executions of "command".
This is typically used to avoid the "argument list too long" problem
when you let the shell expand wildcards on an unknown number of files. 

Of course if the list will never exceed the shell command line buffer
and you know how deep the directory tree goes, you can just use:

command * */* */*/* (etc..)

Les Mikesell
  les at chinet.chi.il.us



More information about the Comp.unix.questions mailing list