it's possible to change "type" with AWK in this code
Code: Select all
FOR /F %%d IN ('type "%2"^|find "" /v /c') DO SET /a cnt_record=%%d
Regards
Dario
Moderator: DosItHelp
Code: Select all
FOR /F %%d IN ('type "%2"^|find "" /v /c') DO SET /a cnt_record=%%d
Code: Select all
awk "END{exit NR}" "%~2"
set cnt_record=%ERRORLEVEL%
Code: Select all
for ..... ('awk .....' ) do (
set records=.....
)
Code: Select all
awk "END{ print \"total count is \"NR}"
2'147'483'647 linesghostmachine4 wrote:what is the maximum number that %errorlevel% can take?
amel27 wrote:not absolutely... file size with such quantity of lines > 4Gb (\r\n + text)
Code: Select all
@echo off
cls
set /a "l=2147483647"
<nul set /p x="lines : "& echo %l%
<nul set /p x="bytes : "& echo %l%*(2+3)
echo.---------------------------
set /a "k=%l%/1024*(2+3)"
<nul set /p x="kilobytes: "& echo %k%
set /a "m=(%k%/1024)"
<nul set /p x="megabytes: "& echo %m%
set /a "g=(%m%/1024)"
<nul set /p x="gigabytes: "& echo %g%
Code: Select all
@echo off
cls
set /a "m=200"
<nul set /p x="megabytes: "& echo %m%
set /a "k=%m%*1024"
<nul set /p x="kilobytes: "& echo %k%
set /a "b=%k%*1024"
<nul set /p x="bytes : "& echo %b%
echo.--------------------
set /a "l=%b%/(2+3)"
<nul set /p x="lines : "& echo %l%
errorlevel = -2147483647ghostmachine4 wrote:file that has 2147483649 lines. So what happens next to %errorlevel% ?
amel27 wrote:most likely for this one "FIND /C" not work as well, since CMD arithmetic is 32-bit integer
as well as all others CMD methods (not errorlevel) - SET /A, FIND, FOR, etc.ghostmachine4 wrote:that's why using errorlevel to capture NR is not recommended