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:
1_find_single_file.bat
----------------------------------
@echo off
find "john" list.txt
pause
2_find_multiple_file.bat
--------------------------------------
@echo off
find /n "john" list.txt list1.txt list2.txt
pause
3_find_multiple_file.bat
_______________________
@echo off
find /i /n "JOHN" *.txt
pause
4_find_c.bat
________________
@echo off
find /c "john" *.txt
pause
5_find_v.bat
____________-_
@echo off
FIND "john" /v list.txt
pause
check ping.bat
________________
@echo off
set ip=google.com
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.
Видео Find/Search a string using Batch File programming канала Ritwik Dasgupta
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:
1_find_single_file.bat
----------------------------------
@echo off
find "john" list.txt
pause
2_find_multiple_file.bat
--------------------------------------
@echo off
find /n "john" list.txt list1.txt list2.txt
pause
3_find_multiple_file.bat
_______________________
@echo off
find /i /n "JOHN" *.txt
pause
4_find_c.bat
________________
@echo off
find /c "john" *.txt
pause
5_find_v.bat
____________-_
@echo off
FIND "john" /v list.txt
pause
check ping.bat
________________
@echo off
set ip=google.com
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.
Видео Find/Search a string using Batch File programming канала Ritwik Dasgupta
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
Batch 76 String FindFor /R, For /D, For /L Loop in Batch File ProgrammingBatch/Cmd Programming: Lesson 1 (Basics)Batch Programing: Lesson 3 (Create Text Files and Extract from them)For (/F) Loop in Batch File ProgrammingCall a function or other Batch file using Batch File ProgrammingBatch Programing: Lesson 4 (How to Copy,Move and Rename files + MORE)Batch - How to Set a Variable from a TXT File (How to Import/Export Data From Files)How to Design Your Life (My Process For Achieving Goals)How To Record Your Computer Screen - for FreeFile Handling in C - INSERT, UPDATE, DELETE, SORT, SEARCH of STUDENT RECORD - IN FILE WITH STRUCTUREBatch Tutorial 10 - FOR LoopsCommand Line Arguments in Batch File ProgrammingHow to edit a batch file (With background music in video)HOW TO (FIND) STRINGS IN FILES AND COMMAND OUTPUTS IN CMD31 Findstr Windows Dos Commands tutotrial System Admin tutorial commandsBat Menü erstellen (Fortgeschrittene)How to get filenames using Batch ScriptIntro to WPF: Learn the basics and best practices of WPF for C#How to ping multiple servers using batch script file