- //&cls&cscript -nologo -e:jscript "%~f0"<"a.txt" "b.txt"&pause&exit
- var str = WSH.StdIn.ReadAll().replace(/[\*\.\?\+\$\^\[\]\(\)\{\}\|\/]/g,'\\$&').split(/\r\n/).join('|');
- var reg = new RegExp('(^|[\\r?\\n])[ \\t]*('+str+').*', 'g');
- var lines = (new ActiveXObject('Scripting.FileSystemObject')).OpenTextFile(WSH.Arguments(0), 1).ReadAll().match(reg);
- WSH.echo(lines.join(''));
复制代码
|