![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 100% ownership to files | Terrible | UNIX for Dummies Questions & Answers | 3 | 12-05-2006 10:40 AM |
| Losing ownership with gzip | superdelic | UNIX for Dummies Questions & Answers | 3 | 07-24-2006 08:36 AM |
| help regarding file ownership | amit007 | Shell Programming and Scripting | 5 | 09-07-2005 02:42 AM |
| ownership of files | szhu | UNIX for Dummies Questions & Answers | 4 | 12-31-2003 09:59 AM |
| Preserving Ownership w/tar | bergerj3 | Filesystems, Disks and Memory | 1 | 02-05-2002 08:53 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
precompressing and ownership
I'm looking for a way to create preprocessed .gz files of static pages to serve up to those browsers that can accept them.
I know I can use: gzip -c --best index.html > index.html.gz to create the .gz file _and_ keep the original. What's the proper command line way to run that on each index.html file in all the subdirectories? There's a way via find and/or xargs, right? Can it be done from the command line, or do I need a script? Also, if I run the cron as a user other than root (i.e. my apache user) will the resulting gzip be owned by apache or do I have to chown it? Thanks for any advice! |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Scripts are just canned command lines; if you can run it from the command line, you can put it in a script, and vice versa.
I believe gzip will preserve ownership of files but you can't use the -c option and redirection then. Of course, the user running the script will need write access to the files and directories you want to modify in any event. Code:
find /path/to/var/www/html-docs/whatever -name 'index.html' -exec gzip -9 {} \;
Code:
find /path/to/var/www/html-docs/whatever -name 'index.html' -print |
xargs -n 1 -i sh -c 'gzip -c -9 < {} >{}.gz'
Code:
#!/bin/sh gzip -c -9 <"$1" >"$1".gz Code:
#!/bin/sh for f; do gzip -c -9 <"$f" >"$f".gz chmod 644 "$f".gz chown www-data:www-data "$f".gz done Code:
find /path/to/var/www/html-docs/whatever -name 'index.html' -print | xargs $HOME/zipper Last edited by era; 08-13-2008 at 11:38 PM. Reason: Noticed you want to keep the originals; add sample script for calling from xargs |
|
#3
|
|||
|
|||
|
Thank you so much! It worked great.
|
|||
| Google The UNIX and Linux Forums |