I\'m trying to run a find
command for all JavaScript files, but how do I exclude a specific directory?
Here is the find
code we\'re using.<
Better use the exec
action than the for
loop:
find . -path "./dirtoexclude" -prune \
-o -exec java -jar config/yuicompressor-2.4.2.jar --type js '{}' -o '{}' \;
The exec ... '{}' ... '{}' \;
will be executed once for every matching file, replacing the braces '{}'
with the current file name.
Notice that the braces are enclosed in single quote marks to protect them from interpretation as shell script punctuation*.
* From the EXAMPLES section of the find (GNU findutils) 4.4.2
man page