本帖最后由 taofan712 于 2017-3-2 13:45 编辑
回复 4# Nsqs
- @echo off&setlocal enabledelayedexpansion
- for /f "delims=" %%a in ('findstr .* a.txt^|find /v /c ""') do set /a ln=%%a,n=1
- echo;%ln%&pause
- for /f "tokens=1* delims=:" %%b in ('findstr /n .* a.txt') do set last=%%c
- echo;%last%&pause
- for /f "tokens=1* delims=:" %%d in ('findstr /n .* a.txt') do (
- if %%d neq %ln% (
- set line=%%e
- echo;!line!
- set /a n+=1
- ) else (
- echo;!last:~0,-2!ba
- )
- )>>2.txt
复制代码
原以为我能写出更简短代码,没想到比我原答案还更多了几行。。。 |