arealhobo
arealhobo

Reputation: 467

For Loop through text file only outputs last line

I think I am about to have an a brain aneurysm. I am trying to print the lines of a text file to a new file, but it only outputs the last line. I have done this a dozen times, now I am not sure what I am doing wrong.

for /F "tokens=*" %%A in (results.txt) do (
   echo %%A
) > imsofrustrated.txt
PAUSE

Am I literally retarded? This is in reference to a previous question I posted. FINDSTR - Stop on last string match

Upvotes: 1

Views: 140

Answers (1)

SomethingDark
SomethingDark

Reputation: 14305

> is to redirect output and overwrite whatever is in the file.
>> is to redirect output and append to the file.

for /F "tokens=*" %%A in (results.txt) do (
   echo %%A
) >> imsofrustrated.txt

Upvotes: 1

Related Questions