Recompressing if not pressent or older than original
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Recompressing if not pressent or older than original
Hi,
I want a shell script that will find all files in a directory (and it's subdirectories) with the file extensions .js, .css, and .png. It should compress files using gzip, leaving the original file and a new with a .gz extension. However if a .gz file is pressent and has an older time stamp than the original file, than the compressed file should be replaced by a newly compressed file. If the time stamp is the same as for the original file than nothing should happen.
I want a shell script that will find all files in a directory (and it's subdirectories) with the file extensions .js, .css, and .png. It should compress files using gzip, leaving the original file and a new with a .gz extension. However if a .gz file is pressent and has an older time stamp than the original file, than the compressed file should be replaced by a newly compressed file. If the time stamp is the same as for the original file than nothing should happen.
How to do this?
(I know what I want, just not how to do it.)
The time-stamp of the original will necessarily always be
older than the gz because your script won't be automatically
running every time you save a new version of one of your files....
The time-stamp of the original will necessarily always be
older than the gz because your script won't be automatically
running every time you save a new version of one of your files....
One of the features of gzip is that it keeps the time stamps of the uncompressed file.
I have a file, original.js. I want a compressed version of that file in the same directory as the file. So I would have original.js and original.js.gz. Now, if I alter original.js then I would want to update the compressed version so that they match. Taking it one step further, say that I have a whole bunch of files in one directory and more files in subdirectories of that directory. Recompressing everything would be time consuming. So I want to recompress files that have been altered only. Using a shell script.
How would I achieve this?
Last edited by Aleksandersen; 12-08-2007 at 04:12 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.