China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-24 05:10
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Remove duplicate lines View 2,471 Replies 16
Original Poster Posted 2008-01-14 09:26 ·  中国 安徽 马鞍山 电信
中级用户
★★
Credits 493
Posts 228
Joined 2007-02-16 00:38
19-year member
UID 79596
Gender Male
From 安徽
Status Offline
There is a text:

Wang A male 340505
Wang B male 340503
Wang A male 340505
Wang B male 340503
Wang B male 340503
Wang C female 340502
Wang A male 340505

Want to eliminate duplicate rows, get

Wang A male 340505
Wang B male 340503
Wang C female 340502

???????
Floor 2 Posted 2008-01-14 09:44 ·  中国 辽宁 本溪 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
```
@echo off
for /f "delims=" %%i in (a.txt) do (
findstr /c:"%%i" b.txt 2>nul||echo %%i>>b.txt
)
pause
```

[ Last edited by jmz573515 on 2008-1-14 at 09:49 AM ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
xycoordinate +2 2009-04-03 06:39
Floor 3 Posted 2008-01-14 10:06 ·  中国 安徽 马鞍山 电信
中级用户
★★
Credits 493
Posts 228
Joined 2007-02-16 00:38
19-year member
UID 79596
Gender Male
From 安徽
Status Offline
Floor 4 Posted 2008-01-14 18:26 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
### bat
@echo %bg% off&SetLocal EnableDelayedExpansion

for /f "delims=" %%a in (a.txt) do (
if not "!%%a!"=="batch" (
echo\
set %%a=batch
)
)
endlocal
pause


### awk
gawk "!a++" a.txt
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
xycoordinate +2 2009-04-03 06:40
Floor 5 Posted 2008-01-14 20:53 ·  中国 重庆 九龙坡区 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
排序
sort -u a.txt
Floor 6 Posted 2008-01-14 21:12 ·  中国 上海 电信
中级用户
★★
Credits 321
Posts 135
Joined 2007-02-04 04:48
19-year member
UID 78578
Gender Male
Status Offline
Originally posted by HAT at 2008-1-14 08:53 PM:
sort
sort -u a.txt


What you said is not for Windows, I see that the sort in Windows XP seems to not have the -u parameter.
Floor 7 Posted 2008-01-14 21:58 ·  中国 重庆 九龙坡区 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Originally posted by honghunter at 2008-1-14 09:12 PM:

What you mentioned is not under Windows, I see that the sort in Windows XP does not have the -u parameter.

Yes
Upon seeing the moderator mention awk, I thought of sort呵呵
Floor 8 Posted 2008-01-14 22:08 ·  中国 山东 烟台 联通
中级用户
★★
Credits 257
Posts 123
Joined 2008-01-05 11:08
18-year member
UID 107722
Gender Male
From 烟台
Status Offline
Learning
路 是自己选的
学习 是为了具备解决问题的能力
Floor 9 Posted 2008-01-15 09:07 ·  中国 四川 达州 电信
新手上路
Credits 10
Posts 4
Joined 2008-01-14 14:08
18-year member
UID 108566
Gender Male
Status Offline
Learning
Floor 10 Posted 2008-01-15 17:09 ·  中国 河北 张家口 电信
初级用户
★★
Credits 123
Posts 54
Joined 2006-12-01 01:16
19-year member
UID 72206
Gender Male
Status Offline
Learned another trick, every time I come here I gain something, heh heh
Floor 11 Posted 2008-01-22 14:25 ·  中国 广西 百色 中移铁通
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
What are the meanings of the moderator's echo %bg% off and echo\[%%a]? May I ask if they can be explained? Also, it can be displayed normally without removing %bg% and \[]
Floor 12 Posted 2008-02-19 18:43 ·  中国 江苏 苏州 电信
银牌会员
★★★
Credits 1,181
Posts 533
Joined 2006-08-14 12:54
19-year member
UID 60484
Status Offline
set %%a=batch
I didn't understand this sentence.
==================
Oh, I didn't get it for a moment, but I figured it out and bumped an old post.

[ Last edited by NaturalJ0 on 2008-2-19 at 06:48 PM ]
Floor 13 Posted 2008-02-19 20:47 ·  中国 浙江 温州 电信
中级用户
★★
Credits 458
Posts 196
Joined 2006-10-05 12:04
19-year member
UID 64614
Status Offline
uniq.exe 1.txt>2.txt
Floor 14 Posted 2008-02-20 09:47 ·  日本 IIJ
初级用户
Credits 34
Posts 14
Joined 2008-02-18 14:13
18-year member
UID 110895
Gender Male
Status Offline
It seems that "!%%a!" might be a specific custom-defined placeholder or an identifier with no universal standard meaning in a general sense. Without more context from the specific context of the China DOS Union forum where this appears, it's difficult to give an extremely precise interpretation. It could be something related to a particular script, macro, or local convention within that forum's discussions.
Floor 15 Posted 2008-02-20 11:48 ·  中国 北京 联通
中级用户
★★
替身
Credits 269
Posts 130
Joined 2007-03-23 21:41
19-year member
UID 82683
Gender Female
Status Offline
Strictly speaking, it would be better if the second floor added the /X parameter
Forum Jump: