Page 1 of 1

Batch commands fail when parsing large text files.

Posted: 10 Aug 2013 00:01
by Endoro
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.

Re: Batch commands fail when parsing large text files.

Posted: 10 Aug 2013 02:43
by foxidrive
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

Re: Batch commands fail when parsing large text files.

Posted: 10 Aug 2013 13:37
by Endoro
foxidrive wrote:BTW, your code is missing some " quotes Endoro..

Thanks foxidrive, it works now :oops: