娜美 当前离线
六级士官
需批量处理多个文件 请问bat如何按指定列来删除重复行 A*B*3 A A*B*C B A*B*C A 需将Tab "\t" 为分隔符 , 不能按 "*" 为分隔符 bat完成按指定第列数值去重复, 例如第 1列, 如果第1列有重复情况, 似乎删那一行都没问题 >*.txt A*B*3 A A*B*C B复制代码
hfxiang 当前离线
上尉
gawk "!x[$1]++" 1.txt>2.txt复制代码
TOP
@echo off setlocal enabledelayedexpansion for /f "delims=" %%x in ('dir /b /a-d *.txt') do ( for /f "useback tokens=1-9* delims= " %%a in ("%%x") do ( if %%h equ 1 ( if not defined %%i ( echo,%%i set %%i=1 ) )))>%%x.txt endlocal pause复制代码
Five66 当前离线
@echo off for %%a in (*.txt) do ( setlocal enabledelayedexpansion (for /f "usebackq tokens=1-2* delims= " %%i in ("%%a") do ( if not defined #%%j ( echo,%%i %%j %%k set #%%j=1 ) ))>"___new-%%a.txt" endlocal ) pause复制代码
77七 当前离线
中校
@echo off for /f "delims=" %%i in ('dir /b /a-d *.txt') do ( cd.>"%%~ni_2%%~xi" for /f "useback tokens=1* delims= " %%a in ("%%i") do ( findstr /bc:"%%a " "%%~ni_2%%~xi" 1>nul if errorlevel 1 ( >>"%%~ni_2%%~xi" echo %%a %%b ) ) ) pause复制代码
terse 当前离线
中将
@echo off set n=2 for /f "delims=" %%i in ('dir /b /a-d *.txt') do ( setlocal enabledelayedexpansion for /f "useback delims=" %%j in ("%%i") do ( for /f "tokens=%n%" %%k in ("%%j") do ( if not defined #%%k ( echo,%%j set #%%k=1 ) ) ) endlocal ) pause复制代码