views:

36

answers:

1

I'm merging (and afterwards minify with YUI compressor) my CSS and JS files. My web application works fine when just linking the separate files.

Now I want to merge the files as one CSS file, so I just basically do the following:

find /myapp/js/ -type f -name "incl_*.js" -exec cat {} + > ./temporary/js_backend_merged.js

That merges all my javascript files perfectly. When I do this on my mac, all goes well and I can use the merged file in my application with no problems

When I merge the same files with the same command on my CentOS server, this doesn't work, my JS start throwing errors. I have the same problem when merging CSS files, the CSS doesn't render correctly on my Centos box when merged. It does when I merge them on my MAC.

Also, I did the same process before on my previous centos server, with no problems at all.

I'm thinking in the direct of a character set problem on the server maybe? Who can solve this little mistery that took 2 complete days of my time already with no luck at all...

UPDATE: the problem is that the command: find /myapp/js/ -type f -name "incl_*.js" -exec cat {} + > ./temporary/js_backend_merged.js orders files from incl_01 to incl_02, ... correctly on the mac, but the same command orders these files differently on the server

I see that I can use sort -n to sort results, but I cant get the above command working correctly with the sort option added to it.

A: 

(find /myapp/js/ -type f -name "incl_*.js" | sort | xargs cat) > ./temporary/js_backend_merged.js

That'll use find the list of files, sort them, then pipe to xargs, takes the list of files from stdin, and applies the 'cat' command to them.

Then the whole thing is redirected to js_backend_merged.js

halkeye
rewrote my script with your sort option, and it works perfect now. Thanks a lot, this stupid sort stuff just cost me 2 days :). Any idea how find is sorting files by default or what is causing this difference between machines?
Jorre
I couldn't find anything in the man pages. I'm a big fan of xargs though.
halkeye