Results 1 to 2 of 2
  1. #1

    Strip whitespace from each line of PHP file

    Hi,

    I have a load of PHP files that need trimming down, so for example
    Code:
    <html>
             <?php
                    $loads_of_stuff = 1231231;
             ?>
    </html>
    change to

    Code:
    <html>
    <?php
    $loads_of_stuff = 1231231;
    ?>
    </html>
    There are 000's of lines, so some awk command or something similiar would be great to execute on each file.

    Thanks
    Stuart Munro

  2. #2
    You could accomplish this with something similar to the following:

    Code:
    perl -pi -e 's/^\s+//g' $(find . -iname '*.php' -type f)
    This would recursively apply this modification to each file ending in .php in the current working directory and beyond. I'm assuming you're planning on never looking at or modifying this code ever again?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •