Support » Fixing WordPress » Remove trailing and leading spaces in .php files

  • 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.

Viewing 1 replies (of 1 total)
  • 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
Viewing 1 replies (of 1 total)
  • The topic ‘Remove trailing and leading spaces in .php files’ is closed to new replies.