- @echo off
- setlocal enabledelayedexpansion
- (for /f "tokens=1,2,*" %%a in ('sort a.txt') do (
- if "%%a" neq "!last_col1!" (
- if defined last_col1 (
- echo !full_line!
- )
- set last_col1=%%a
- set n=%%b
- set full_line=%%a %%b %%c
- ) else (
- if %%b lss !n! (
- set n=%%b
- set full_line=%%a %%b %%c
- )
- )
- )) >result.txt
复制代码
|