在 [ 随风] 的基础上改了一下,做到不重复,完全随机(16楼sort方法,有些行是永远也取不到的),不生成临时文件-
- @echo off&setlocal enabledelayedexpansion
- set /a n=10
- for /f "tokens=2 delims=:" %%a in ('find /v /c "" a.txt')do set/a h=%%a
-
- for /l %%a in (1,1,%n%) do (
- set/a v=!random!%%h+1
- for /l %%b in (1,1,%n%) do (
- if defined tem!v! (set /a v=v%%n+1)
- )
- set tem!v!=y
- set var=!var! !v!:
- )
- for /f "tokens=1* delims=:" %%a in ('findstr /n .* a.txt^|findstr /b "!var!"') do echo %%b
- pause
复制代码
[ 本帖最后由 netbenton 于 2009-6-2 20:09 编辑 ] |