本帖最后由 WHY 于 2023-6-6 09:38 编辑
bat+JS 试试- @if(0)==(0) echo off
- pushd "%~dp0"
- type 1.txt | cscript //nologo //e:jscript "%~f0" > 2.txt
- pause & exit/b
- @end
-
- var map = {};
- var num = 100000000;
-
- var str = WSH.StdIn.ReadAll();
- var arr = str.replace(
- /^(\S+)[^\r\n]*(?=\r\n|$)/mg,
- function(s0, s1){
- if (!map.hasOwnProperty(s0)){
- map[s0] = true;
- return s1 + ++num + ' ' + s0; //每一行添加数字
- } else {
- return ''; //去重复
- }
- }
- ).split('\r\n').sort();
-
- str = arr.join('\r\n').replace(/^\S+ /mg, ''); //删掉每一行添加的数字
- str = str.replace(/^(?:\r\n)+/, ''); //删掉开头的回车换行
- WSH.Echo(str);
复制代码
|