Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

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

 
discard

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.