Tuesday, January 8, 2008

JsGrep - grep in JScript

JsGrep - an OO-ish implementation of grep in JScript (CodeProject)
Shows how the object features of JScript can be put to use in a useful utility script
Download source - 2 Kb

Using the code
The code should be run under using the Windows Scripting Host (WSH) Console client, cscript.exe, e.g.:
cscript jsgrep.js -il "MyHeader\.h" *.cpp
To set the console client to be the default, use: cscript /H:cscript
You can then run the utility simply with:
jsgrep -il "MyHeader\.h" *.cpp
To run the utility under the Windows Script Debugger, if installed, use:
cscript //x jsgrep.js -il "MyHeader\.h" *.cpp

No comments: