Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is a linux shell command which will comment all require_once calls from certain directory in php files:

  % cd path/to/ZendFramework/library
  % find . -name '*.php' -not -wholename '*/Loader/Autoloader.php' \
    -not -wholename '*/Application.php' -print0 | \
    xargs -0 sed --regexp-extended --in-place 's/(require_once)/\/\/ \1/g'

But how could I do that in Windows OS cmd?

This is to speed up a Zend Framework application.


On one line:

find . -name '*.php' -not -wholename '*/Loader/Autoloader.php' -not -wholename */Application.php' -print0 | xargs -0 sed --regexp-extended --in-place 's/(require_once)/\/\/ \1/g'
share|improve this question
up vote 3 down vote accepted

With this and this.

share|improve this answer
Is syntax the same? Tha above code does not work ("FIND: Parameter format not correct", "'-not' is not recognized as an inte operable program or batch file.", "'xargs' is not recognized as an in operable program or batch file."). – Richard Knop Oct 14 '10 at 7:05
The backslash continuation operator is not usually found in cmd.exe I think. Remove them and input it as one continuous line. – Ignacio Vazquez-Abrams Oct 14 '10 at 7:08
"'xargs' is not recognized as an in operable program or batch file." – Richard Knop Oct 14 '10 at 7:11
It is there in findutils. It might not be in your %PATH% though. – Ignacio Vazquez-Abrams Oct 14 '10 at 7:18

FYI, on Windows, I could not get xargs working for some reason, but this is the command I ran through Git Bash shell:

find . -name '*.php' -print0 | xargs -0 sed --regexp-extended --in-place 's/(require_once)/\/\/ \1/g'

Then, manually recopy the Loader.php and Application.php file back over the sedited ones.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.