Closed Anatolich closed 6 years ago
Problem solved.
This behavior is due to the peculiarities of the find command, in a bunch with the specified exec parameter in the example {} \;
In this case, output result of the find, processed as though if in a cycle, submitting the results one by one, executing the command specified in exec every time, for each item.
For us, it is necessary to accumulate the result and submit him, in to the input yuicompressor.
A special parameter must be specified in the format {} +
and not {}
to transfer a single accumulated parameter.
Working variant for the given example:
sudo find /path/to/css/ -type f -name '*.css' -not -name '*.min.css' -exec yui-compressor -o '.css$:.min.css' {} +
Please give me an explanation, in my problem. I want to compress multiple css files or js, by given following bash:
sudo find /path/to/css/ -type f -name '*.css' -not -name '*.min.css' -exec yui-compressor {} -o '.css$:.min.css' \;
But this isn't work, he create a .css$:.min.css file, in root folder by default.
Ok fine, now get a trick:
sudo find /path/to/css/ -type f -name '*.css' -not -name '*.min.css' -exec yui-compressor /path/to/css/batch_css_1.css /path/to/css/batch_css_2.css /path/to/css/batch_css_3.css -o '.css$:.min.css' \;
And this code work fine.
What the difference in input param?