Search And Replace
The search script allows to find or replace either a plain-text string or a token in a file or a set of files.
Command line and options for searching
Once the file compiled in binary the syntax of the command is:
search [options] string files
with PHP the command is
php search.php [options] string files
The file argument may be a single filename or a definition with wildcard,
for example *.* for alls files in the directory. The ? wildcard is also
supported.
Example:
search string myfile.html search string *.html search string *.htm?
The command is not recursive, it applies only to the current directory
or the given path.
Options may be concatenated, for example -ic is equivalent to -i -c.
Options
-i ignore case for the string and the content of the file, the default is case-sensitive. -c searches for identifiers and use special characters of C as separators. -f display all parsed files, by default display only the filename with the matches. -u case-sensitive on filenames as of Unix, by default ignores case of filenames.
Command for replacing
To replace a string by another one in a set of files, the command is:
search [options] string1 string2 files
The presence of a second string, that is the replacing string, while the first one is the string to replace, is sufficient to turn the script into a replacing tool.
Download
- Search, the zip archive holds an executable for Windows, a PHP version for any system with PHP 4 or 5 enabled, and the Scriptol source.
- Compiler.
Permission is granted to print this page and the code of the scripts and to use freely the code.
Don't display this page and the code on another website.