ramfree17 Posted November 27, 2003 Report Share Posted November 27, 2003 Hi, Im trying to create a script which will process a whole directory tree but skip processing files which contains certain characters. Can somebody tell me how to make bash (or another utility that has a cygwin port) a directive that is something like "skip file if filename contains the character X, otherwise process it with the rest"? thanks. ciao! Quote Link to comment Share on other sites More sharing options...
spinynorman Posted November 27, 2003 Report Share Posted November 27, 2003 Is this article on filename globbing what you need? :unsure: Quote Link to comment Share on other sites More sharing options...
ramfree17 Posted November 27, 2003 Author Report Share Posted November 27, 2003 i might be missing it but i dont think this would help. im basically doing a directory walker. it will list the contents of the specified directory and process each entry. if the entry is a regular file then the script will pass it off to another utility for further processing but if it is a directory then it will process it again by listing its contents and so on until the directory structure has been processed. thanks anyway. ciao! Quote Link to comment Share on other sites More sharing options...
johnnyv Posted November 27, 2003 Report Share Posted November 27, 2003 I have php scripts that do that sort of thing if you want i could post some examples. For example i have one that searches through all directories from a specifiec base directory and finds all pdf files then runs ps2ascii on all the pdfs via shell_exec(). Quote Link to comment Share on other sites More sharing options...
fuzzylizard Posted November 27, 2003 Report Share Posted November 27, 2003 the 'find' command piped through to the processing command may be able to accomplish this. Something like $ find . -name * | cat Or some variation thereof may do what you need. There are several switches for find that will limit it to only looking at regular files and it acts recursively by nature so therefore, will process all files below the directory you specify. Otherwise, perl or ruby or python may be the next best solution for what you are looking for. Quote Link to comment Share on other sites More sharing options...
ramfree17 Posted November 28, 2003 Author Report Share Posted November 28, 2003 thanks guys. the script is pretty much stable at the moment with the added quirk that it processes the *$* files as well. fwiw, i am decompiling a directory of classes for review and i dont technically need to decompile inner classes. ill take a look at the find solution (assuming i can figure out the correct regexp, being regexp is one of the weakest linux skills). ciao! Quote Link to comment Share on other sites More sharing options...
Qchem Posted November 28, 2003 Report Share Posted November 28, 2003 Couldn't you just use a for loop and the test command? That said you'd still need reg expressions. Quote Link to comment Share on other sites More sharing options...
ramfree17 Posted November 28, 2003 Author Report Share Posted November 28, 2003 Couldn't you just use a for loop and the test command? That said you'd still need reg expressions. i am using a for loop+test combo. what i cant figure out is how to test the existence of the dollar sign in the name of the file i am currently processing. ciao! Quote Link to comment Share on other sites More sharing options...
Qchem Posted November 28, 2003 Report Share Posted November 28, 2003 (edited) would a regexp of something like /.*\$.*/ not match anything with a dollar in it? Or indeed /\$/ Edited November 28, 2003 by Qchem Quote Link to comment Share on other sites More sharing options...
ramfree17 Posted November 28, 2003 Author Report Share Posted November 28, 2003 would a regexp of something like /.*\$.*/ not match anything with a dollar in it? probably, but how do i integrate that with the test built-in? my only problem is that using that with find will entail me to do some more cutting on the path. but i will consider that until something better comes up. thanks. ciao! Quote Link to comment Share on other sites More sharing options...
Qchem Posted November 28, 2003 Report Share Posted November 28, 2003 Hmm, I have no idea if test works with regexps so maybe it's best to dump that idea. Incidently is it not a little foolish to have files with a $ in the name, bash will want to expand the $ as a variable. I've suddenly realised this is a bit easier than I thought, just use grep - pipe the current filename to grep '\$' which will match anything with a dollar in, if the return is zero process the file (or whatever you want to do with it) otherwise skip Quote Link to comment Share on other sites More sharing options...
Cannonfodder Posted November 28, 2003 Report Share Posted November 28, 2003 Maybe something in here might help? http://www.mandrakeusers.org/index.php?sho...t+file+find+aru Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.