filmov
tv
Find/Search a string using Batch File programming

Показать описание
This tutorial is about Find a string from any file or a command output. This tutorial is very useful while processing a output or storing an output to a file and then searching for a specific string in it.
For example, If you want to find your system configurations like os, build, ip or any output, You can use find to get that easily.
Syntax:
FIND [/V] [/C] [/N] [/I] "string" [pathname(s)]
"string" : The text string to find (must be in quotes).
[pathname] : A drive/file(s) to search.
/V : Display all lines NOT containing the specified string.
/C : Count the number of lines containing the string.
/N : Display Line numbers.
/I : Ignore the case of characters when searching for the string
Error Levels:
0 if the string is found in any of the files specified
1 if not found
examples:
----------------------------------
@echo off
pause
--------------------------------------
@echo off
pause
_______________________
@echo off
find /i /n "JOHN" *.txt
pause
________________
@echo off
find /c "john" *.txt
pause
____________-_
@echo off
pause
________________
@echo off
ping -n 1 %ip% | find "Reply from"
if not errorlevel 1 set error=live
if errorlevel 1 set error=dead
cls
echo Result: google is %error%
pause
Please subscribe to my channel for new technology videos.
For example, If you want to find your system configurations like os, build, ip or any output, You can use find to get that easily.
Syntax:
FIND [/V] [/C] [/N] [/I] "string" [pathname(s)]
"string" : The text string to find (must be in quotes).
[pathname] : A drive/file(s) to search.
/V : Display all lines NOT containing the specified string.
/C : Count the number of lines containing the string.
/N : Display Line numbers.
/I : Ignore the case of characters when searching for the string
Error Levels:
0 if the string is found in any of the files specified
1 if not found
examples:
----------------------------------
@echo off
pause
--------------------------------------
@echo off
pause
_______________________
@echo off
find /i /n "JOHN" *.txt
pause
________________
@echo off
find /c "john" *.txt
pause
____________-_
@echo off
pause
________________
@echo off
ping -n 1 %ip% | find "Reply from"
if not errorlevel 1 set error=live
if errorlevel 1 set error=dead
cls
echo Result: google is %error%
pause
Please subscribe to my channel for new technology videos.
Комментарии