Skip to content
Д. Безбородов edited this page Oct 30, 2018 · 4 revisions

Command-line Usage

Iterating over a directory structure.

By default, the CLI tool directs output to STDOUT. It does not actually alter the file. In order to alter the file, one may use the following command below. Note that sponge is within the moreutils package, and will need to be installed on your system beforehand.

find . -name '*.php' -exec sh -c "php ~/MySQLConverterTool-master/cli.php -f {} | sponge {}" \;

If anything else such as variable names needs to be replaced, use sed:

find . -name '*.php' -exec sed -i 's/find/replace/g' {} \;

If for some reason empty lines are introduced on the first line of the file, they can be tidied up with:

find . -name '*.php' -exec sed -i '1{/^$/d}' {} \;

Use with care.

Clone this wiki locally