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.

EDIT:

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'
link|improve this question

feedback

2 Answers

up vote 3 down vote accepted

With this and this.

link|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
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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