Question
I'm trying to run a find command for all javascript files, but I need to exclude a specific directory. Here is the find code we're using.
- for file in $(find . -name '*.js'); do java -jar config/yuicompressor-2.4.2.jar --type js $file -o $file; done
Use the prune switch, for example if you want to exclude the misc directory just add a -path ./misc -prune -o to your find command:
Here is an example with multiple directories:
Here we exclude dir1, dir2 and dir3, since in find expressions it is an action, that acts on the criteria -path dir1 -o -path dir2 -o -path dir3 (if dir1 or dir2 or dir3), ANDed with type -d. Further action is -o print, just print.
Supplement
* 35 Practical Examples of Linux Find Command
沒有留言:
張貼留言