本帖最后由 pcl_test 于 2016-7-9 01:36 编辑
- //&cls&cscript -nologo -e:jscript "%~f0"<"1.txt"&pause&exit
-
- var n=5;
- var c='-'; //指定分隔符
- var txt = WSH.StdIn.ReadAll().split(/\r\n/), a={}, b={}, s='';
- for(var i=0;i<txt.length; i++){
- var str = txt[i].split(c)[0];
- a[str]?a[str]++:a[str]=1;
- b[str]?b[str]+=txt[i]+'\r\n':b[str]=txt[i]+'\r\n';
- }
- for(var i in a){if(a[i] < n)s+=b[i];}
- //(new ActiveXObject('Scripting.FileSystemObject')).OpenTextFile('结果.txt', 2, true).Write(s);
- WSH.echo(s);
复制代码
|