文件太大了BAT会吃不住- @echo off&setlocal enabledelayedexpansion
- for /f "delims=" %%i in (a.txt) do set "_%%i"
- for /f "delims=" %%i in (b.txt) do (
- if defined _%%i (
- echo !_%%i!
- ) else echo;%%i
- )
- pause
复制代码 JS的- @if (0)==(0) echo off
- cscript //nologo //E:JScript "%~0"<"b.txt" "a.txt"
- pause&exit
- content
- @end;
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- function adoLoadText(filename, charset) {
- var stream, text;
- stream = new ActiveXObject("ADODB.Stream");
- stream.type = 2;
- stream.charset = charset;
- stream.open();
- stream.loadFromFile(filename);
- text = stream.readText(-1);
- stream.close();
- return text;
- }
- var text = adoLoadText(WScript.Arguments.Item(0), 'utf-8');
- var arr = [];
- var newfile = 'c.txt';//保存文件
- while (!WScript.StdIn.AtEndOfStream){
- var str = WScript.StdIn.Readline();
- var re = new RegExp(str + "=(.+)","i");
- var r = text.match(re)
- arr.push(r?r[1]:str)
- }
- var f = fso.OpenTextFile(newfile,2,true,false);
- f.WriteLine(arr.join('\n'));
- f.Close()
复制代码
|