文件大的话 用外部比较好
外部 GAWK- gawk "{t=substr($0,0,11);n[t]++;a[t]=$0} END{for(m in n) if (n[m]<=1) print a[m]}" a.txt
复制代码 如钟情BAT 有点吃力 看文件大小- @echo off&setlocal enabledelayedexpansion
- for /f "delims=" %%i in (a.txt) do (
- set str=%%i&set "str=!str:~,11!"
- if not defined #!str! (
- set/a"n+=1"
- set #!str!=#&set "$!n!=%%i"
- ) else set "#!str!=$"
- )
- for /l %%i in (1 1 !n!) do (
- set str=!$%%i!
- for %%j in ("!str:~,11!") do if !#%%~j!# ==## echo !$%%i!
- )
- pause
复制代码
- @echo off&setlocal enabledelayedexpansion
- for /f "delims=" %%i in (a.txt) do (
- set str=%%i&set "str=!str:~,11!"
- set /a "$!str:~,11!+=1"
- )
- for /f "delims=" %%i in (a.txt) do (
- set str=%%i
- for %%j in ("!str:~,11!") do if "!$%%~j!" == "1" echo %%i
- )
- pause
复制代码
|