- @echo off
- setlocal enabledelayedexpansion
- for /f %%i in ('sort 1.txt') do (
- if "%%i" == "!s!" (set /a n+=1) else (set n=101)
- echo;%%i!n:~-2!
- set "s=%%i"
- )
- pause
复制代码 如果不希望打乱顺序,可以这样,兼容性稍差- @echo off
- setlocal enabledelayedexpansion
- for /f %%i in (a.txt) do (
- if defined _%%i (set /a _%%i+=1) else (set _%%i=101)
- echo;%%i!_%%i:~-2!
- )
- pause
复制代码
|