Find/Search a string using Batch File programming

preview_player
Показать описание
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.
Рекомендации по теме
Комментарии
Автор

How do i store the return value of find command. based on the return value i need to perform some operation

mdhabeeburrehman
Автор

How can i find a string and if not available, i need to Fail my build in jenkins, pls guide?

pradeepkumarvenkata
Автор

Hi, How to change the file extension if the content inside it matches with the regex pattern ?

jitendrasharma
Автор

i need batch file to search 2nd word in 4th line of every text file in a directory and set that word in variable and print on the display

SubhashKumar-lnge
Автор

Please me that how to add findable string in the variable?

mukamalakmal
Автор

Can you tell me how to replace a certain text in a file using batch programming

abhisheksangwan
Автор

How to get current day of the week? Can you help here?

RS-uige
Автор

I just saw the video. it is awesome. I have a question, If I want to find url from a all folder how to do that.

shaikkhasimsaheb
Автор

Sir I want to create batch for laptop fictional test, please can you help me

anupnadagouda
Автор

how replace a string found with a find in a text file ?

MT-tezc
Автор

How to get last word in file using batch script

rajeshdevada
join shbcf.ru