Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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.