Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!stat!sun13!prism!gt0178a From: gt0178a@prism.gatech.EDU (BURNS,JIM) Newsgroups: comp.unix.questions Subject: Execute a command w/wildcards & recursive descent Keywords: find lsr recursive descent Message-ID: <13204@hydra.gatech.EDU> Date: 31 Aug 90 02:15:53 GMT Organization: Georgia Institute of Technology Lines: 73 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 {}' \; or any other equivalent Unix command? Obviously, I could do find . -type d -exec scriptfile {} \; and use $1 in the script any way I choose, but I don't want a different script for every command I would want to use. If the solution uses 'find', it must do the equivalent of evaluating '{}/wildcardpattern' for those commands that want a list of filenames, not just a directory name, even though something like '{}/*' is unexpandable in 'find'. The program uses the SysV function ftw(3c) and could be executed with the command 'ftw startdirectory unixcommand commandparms', e.g. 'ftw /usr/include grep pattern \*.h'. #include #include #include char command[80]; int walk(); main(argc,argv) int argc; char *argv[]; { int ftwrtn,i; if (argc < 3) printf("USAGE: ftw path command\nargc=%d\n",argc); else { strcpy(command,argv[2]); for (i=3;i