troubleshooting Question

Removing unwanted whitespace and funny characters from end of scripts

Avatar of hankknight
hankknightFlag for Canada asked on
Linux
5 Comments1 Solution1998 ViewsLast Modified:
Hello,

I have a directory containing lots of PHP scripts with unwanted trailing characters.

For example:

      <?php
      phpinfo();
      ?>ÿ
      ÿ
      ÿ
      ÿ
      ÿÿ

The scripts should end with ?> and NOT with newlines or ÿ.

So if ANY .php file contains ANYTHING after the last ?> that is NOT 0-9 or a-Z then I want EVERYTHING after the last ?> to be REMOVED.

How can I do this for all scripts in a directory and its sub-directories (recursively)?  Keep in mind that some PHP scripts contain several <? and ?> and I only want to check for the very last ?>

Thanks!
ASKER CERTIFIED SOLUTION
bartelar

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros