WordPress.org

Ready to get started?Download WordPress

Forums

Remove trailing and leading spaces in .php files (2 posts)

  1. David Radovanovic
    Member
    Posted 6 years ago #

    I'm trying to search for a script that will remove all leading and trailing spaces in my php files. The reason besides compacting files is that the feeds are broken. One of the many files within WordPress has placed 2 spaces above the doc declaration and I'm not finding the culprit.

  2. David Radovanovic
    Member
    Posted 6 years ago #

    find ./ -name "*.php" -exec sed -i -e 's/^\s*//' {} \;
    this will remove left spaces tab etc
    
    find ./ -name "*.php" -exec sed -i -e 's/\s*$//' {} \;
    this will remove right spaces before new line
    
    find ./ -name "*.php" -exec sed -i -e '/^\n*$/d' {} \;
    delete blank empty lines

Topic Closed

This topic has been closed to new replies.

About this Topic