Hi,
I need a Dos batch file command to, find/search specified word "Dostips" in last line of specified c:\a.txt file and if found run 1.txt file if not then go to loop and keep monitoring file.
Thanks
find/search specified word "Dostips" in last line
Moderator: DosItHelp
Re: find/search specified word "Dostips" in last line
Code: Select all
@echo off &setlocal enableextensions
:loop
for /f "tokens=1,* delims=]" %%k in ('find /n /v "" a.txt') do (
echo "%%l"|findstr /c:"Dostips" >nul &&set find=Yes||set find=)
if not "%find%"=="Yes" (ping -n 2 127.0.0.1 >nul &goto :loop)
start 1.txt
Re: find/search specified word "Dostips" in last line
!K
Wahoo,,, U r an expert. It worked great.
Please One more thing to make sure word is not missed, If it is possible that instead of only looking last line, If it can look for word "Dostips" in Last 10 lines of A.txt file? if match found run 1.txt other wise goto Loop and keep monitoring the file.
Thanks in Advance
Wahoo,,, U r an expert. It worked great.
Please One more thing to make sure word is not missed, If it is possible that instead of only looking last line, If it can look for word "Dostips" in Last 10 lines of A.txt file? if match found run 1.txt other wise goto Loop and keep monitoring the file.
Thanks in Advance
Re: find/search specified word "Dostips" in last line
Code: Select all
@echo off &setlocal enableextensions
set "log=c:\a.txt"
:loop
ping -n 2 127.0.0.1 >nul
for /f "delims=[]" %%l in ('find /n /v "" "%log%"') do set /a line=%%l-10
if %line% LSS 0 set /a line=0
more +%line% "%log%" |findstr /c:"Dostips" >nul &&start 1.txt ||goto :loop
Re: find/search specified word "Dostips" in last line
Wahoo, Impressive. You r the Star!!!
I searched the net but no luck!!
I gave this question on other forums but no reply.
But solved it in minutes.
Thank you very very much. God bless u all the time.
I searched the net but no luck!!
I gave this question on other forums but no reply.
But solved it in minutes.
Thank you very very much. God bless u all the time.