for /f "delims=" %%i in (test.txt) do if not defined %%i set %%i=a&echo %%i
江湖远
碧空长
路茫茫
一个人漫无目的的奔跑,风,刺骨的冷....
碧空长
路茫茫
一个人漫无目的的奔跑,风,刺骨的冷....
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!
Originally posted by everest79 at 2007-4-21 04:41:
My this one can only delete the repeated lines
a
a
b
c
d
a
b
c
d
Cannot
a
a
b
c
d
b
c
d
src.txt is your original text, after execution, dst.txt is the filtered text. Switch the cmd to the directory where src.txt is saved, then execute the above line
@echo off
setlocal enabledelayedexpansion
cd.>temp.txt
for /f "tokens=* delims=:" %%i in ('findstr /n ".*" test.txt') do (
echo %%i>>temp.txt
)
for /f "tokens=1* delims=:" %%m in (temp.txt) do (
for /f "tokens=1* delims=:" %%x in ('findstr /v /c:"%%m:" temp.txt') do (
if "%%n"=="%%y" (
set str=%%y !str!
)
)
)
findstr /v "!str!" test.txt
pause
Originally posted by chishingchan at 2007-9-26 22:22:
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 & ech ...
Originally posted by bray at 2008-8-28 05:42 PM:
What is the use of `set %%i=a`?