Batch commands fail when parsing large text files.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Endoro
Posts: 244
Joined: 27 Mar 2013 01:29
Location: Bozen

Batch commands fail when parsing large text files.

#1 Post by Endoro » 10 Aug 2013 00:01

At first I make a large text file:

Code: Select all

(for /l %%a in (1,1,16000) do @echo(0123456789012345678901234567890123456789)>file


and test some commands from a batch file

Code: Select all

@echo off &SETLOCAL
SET section=123"
SET target=456"
SET base=file"

ECHO start
for /F "delims=:" %%a in ('findstr /NC:"%SECTION%" /C:"%TARGET%" "%BASE%"') do ECHO(%%a
find /N "%SECTION%%TARGET%" "%BASE%
sed "/./!d" "%base%"
grep "123" "%base%"

None of them works. But all work usually at the command prompt. Tested with XP and Win8.
The issue is associated with this question at SO.

Why does this not work and is there a workaround?
Thank you.

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: Batch commands fail when parsing large text files.

#2 Post by foxidrive » 10 Aug 2013 02:43

I simplified the test case - it prints all 16000 lines in Win 8 32bit.
It works in XP pro too.

BTW, your code is missing some " quotes Endoro..

Code: Select all

(for /l %%a in (1,1,16000) do @echo 0123456789012345678901234567890123456789)>file

@echo off

ECHO start
for /F "delims=" %%a in ('findstr /N /C:"123" /C:"456" "file"') do ECHO %%a
echo end
pause
findstr /N /C:"123456" "file"
pause

Endoro
Posts: 244
Joined: 27 Mar 2013 01:29
Location: Bozen

Re: Batch commands fail when parsing large text files.

#3 Post by Endoro » 10 Aug 2013 13:37

foxidrive wrote:BTW, your code is missing some " quotes Endoro..

Thanks foxidrive, it works now :oops:

Post Reply