Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a deploy script that git pulls code from a repo. I'd like to minify the javascript (js) and css files in that deploy script using yuicompressor.

In order to minify one js file you'd use something like this:

java -jar yuicompressor-2.4.2.jar test.js -o test.js

How can I do that to all js and css files recursively (inside subdirectories and across all files while excluding files that aren't js or css)?


share|improve this question

1 Answer 1

up vote 2 down vote accepted

You can use find + exec

$ find . \( -iname *.js -o -iname *.css \) -exec java -jar /full/path/to/yuicompressor-2.4.2.jar {} -o {} \;

Run it on the root directory of where are your .css and .js are.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.