Загрузка страницы

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
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
11 марта 2018 г. 13:55:48
00:10:35
Яндекс.Метрика