In all sub-directories gzip all *.html and *.php files

Posted on 2006-05-22
Last Modified: 2013-12-16

in all sub-directories gzip all *.html and *.php files

How do i do that in linux
Question by:gg234
    LVL 16

    Accepted Solution


    You could do the following:

    find /var/www -name *.htm -exec gzip -9 {} \; && find /var/www -name *.php -exec gzip -9 {} \;  

    Replace /var/www path with tha path of where you want to start.
    LVL 10

    Author Comment

    i want to gzip the files menctioned files in all subdirectories
    LVL 43

    Expert Comment

    The above does, and just little fix/improvement to have just one call
    find /var/www -type f -name '*.html' -o -name '*.php' -exec gzip -9 {}\;

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Currently, there is not an RPM package available under the RHEL/Fedora/CentOS distributions that gives you a quick and easy way to allow PHP to interface with Oracle. As a result, I have included a set of instructions on how to do this with minimal …
    Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now