Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi every body
I need to count the number of line in a file. My file is like this:
|tetrte|ezrzer|||||erez|
|tetrte|ezrzer|||||erez|
|tetrte|ezrzer|||||erez|I found something: find /C "|" filename
I am a newbie in Dos so don't manage to get the result number in a single variable.
Set toto = find /C "|" filename...Thx for help,
Smilaou

I see that i can redirect the count in a file but on the same line i need to write a message:
echo fin 'The count' > filenamethis don't work :(

Hi smilaou...
I think this is what you need... try it!
echo e100'set %%1='> %temp%.\temp.bat
for %%? in (rcx 7 w q) do echo %%?>> %temp%.\temp.bat
type %temp%.\temp.bat |DEBUG %temp%.\temp.bat > nulrem Find the count in (somefile.ext)
find /c "|" < somefile.ext >> %temp%.\temp.bat
rem: sets result of FIND to the variable "number"
call %temp%.\temp.bat number
del %temp%.\temp.batecho Finished The count is %number% > result.ext
set number=
:eof
result.ext would have one line as this " Finished The count is 5" for example
dual

A rather simpler one-liner can be found here:
http://discussions.virtualdr.com/showthread.php?s=&threadid=146504

Thats a good one Rambler
However it's not clear if the file would contain other unknown characters not specified in /V
if so the count would be inacurate, also no %variable% is set and no echo of the desired line to a fileJust a thought? im learning here too
Dual

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |