Using below I was able to count total number of occurrences of a single word and getting result as given below.
@echo off
set "word=Windows"
set file=log.txt
set cnt=0
for /f ^"eol^=^
delims^=^" %%a in ('"findstr /i "/c:%word%" %file%"') do set "ln=%%a"&call :countWord
echo Server_Type Total_Users >result.txt
echo %word% %cnt% >>result.txt
exit /b
:countWord
setlocal enableDelayedExpansion
:loop
if defined ln (
set "ln2=!ln:*%word%=!"
if "!ln2!" neq "!ln!" (
set "ln=!ln2!"
set /a "cnt+=1"
goto :loop
)
)
endlocal & set cnt=%cnt%
exit /b
result.txt
Server_Type Total_Users
Windows 24
now i want to add 6 new words like Linux, MacOS, Andriod, Unix....etc to search for in the same log file and get result in same format.
but not getting how to achieve that using FINDSTR and Is that possible given the limited RegExp capability of Findstr ? any suggestion please ?