![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-29 00:16 |
47,813 topics / 349,918 posts / today 0 new / 48,278 members |
| DOS批处理 & 脚本技术(批处理室) » Please clarify the specific content or context of "删掉所有重复行" in the batch processing. Because there are different implementation methods for deleting different types of duplicate lines in different scenarios. For example, if it is a text file with lines of text, the general idea is to read line by line, store it in a temporary variable or array, and then judge whether it has been stored before. If not, it is written to a new file. But the specific batch code needs to be further determined according to the actual situation. Please provide more details. |
| Printable Version 2,525 / 23 |
| Floor16 huzixuan | Posted 2007-04-21 07:37 |
| 高级用户 Posts 219 Credits 537 From 芜湖 | |
|
for /f "delims=" %%i in (test.txt) do if not defined %%i set %%i=a&echo %%i
|
|
| Floor17 everest79 | Posted 2007-04-21 10:05 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
| Floor18 waynebeat | Posted 2007-04-21 10:52 |
| 初级用户 Posts 28 Credits 84 | |
| Floor19 scriptor | Posted 2007-09-26 14:20 |
| 银牌会员 Posts 555 Credits 1,187 | |
Originally posted by everest79 at 2007-4-21 04:41: Hahaha.... Finally found it What I want is this Give a thumbs up.... |
|
| Floor20 chishingchan | Posted 2007-09-26 22:22 |
| 银牌会员 Posts 538 Credits 1,284 | |
|
The code on floor 16 doesn't work
D:\DOCUME~1\ADMINI~1>for /f "delims=" %i in (test.txt) do if not defined %i set %i=a&echo %i D:\DOCUME~1\ADMINI~1>if not defined aa set aa=a & echo aa D:\DOCUME~1\ADMINI~1>if not defined bb set bb=a & echo bb D:\DOCUME~1\ADMINI~1>if not defined cc set cc=a & echo cc D:\DOCUME~1\ADMINI~1>if not defined dd set dd=a & echo dd D:\DOCUME~1\ADMINI~1>if not defined bb set bb=a & echo bb D:\DOCUME~1\ADMINI~1>if not defined cc set cc=a & echo cc D:\DOCUME~1\ADMINI~1>if not defined ee set ee=a & echo ee D:\DOCUME~1\ADMINI~1> |
|
| Floor21 yoyodos | Posted 2007-09-26 23:26 |
| 初级用户 Posts 59 Credits 128 | |
|
::)
[ Last edited by yoyodos on 2007-9-26 at 11:28 PM ] |
|
| Floor22 terse | Posted 2007-09-26 23:52 |
| 银牌会员 Posts 946 Credits 2,404 | |
Originally posted by chishingchan at 2007-9-26 22:22: The one on floor 16 should be okay! @echo off for /f "delims=" %%i in (test.txt) do if not defined %%i set %%i=a&echo %%i>>test2.txt pause |
|
| Floor23 bray | Posted 2008-08-28 17:42 |
| 新手上路 Posts 7 Credits 14 | |
|
The sentence "set %%i=a" is used to set the variable represented by %%i to the value "a". In the context of this `for /f` loop, it's likely part of a process to initialize or assign a default value to each variable that is read from the `test.txt` file.
|
|
| Floor24 bray | Posted 2008-08-28 18:05 |
| 新手上路 Posts 7 Credits 14 | |
Originally posted by bray at 2008-8-28 05:42 PM: Also, if you just want to delete adjacent duplicate lines, how to do it? For example: aaa aaa bbb aaa aaa aaa ccc ddd ccc The desired result after processing is: aaa bbb aaa ccc ddd ccc |
|
| Prev 1 2 |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |