I hardly know scripting commands in DOS/Windows Console so I struggle everytime I encounter situations when I need to use them. Case in point is searching for text in files. In Unix, it is easily done via grep but in Windows Console, I only found out that the equivalent command is find. Take note that in Unix/Linux, “find” is used for a completely different thing — finding files.

Syntax:

find "Text to Find" filename.ext


Here’s the example :

E:\siebsrvr\BIN>find "Connected to 1 server" siebs*.log /n /i
---------- SIEBSRVR101.LOG
[22]Connected to 1 server(s) out of a total of 1 server(s) in the enterprise

The slash n (/n) is a parameter to show the line number where the string appears. The slash i (/i) is to ignore the case of the characters.

If I want to find number of lines containing the string (case insensitive), then I should run the command below.

E:\siebsrvr\BIN>find "Connected to 1 server" siebs*.log /c /i
---------- SIEBSRVR101.LOG : 1

source:
http://www.tipsandtricks-hq.com/equivalent-of-unix-grep-command-in-doswindows-726

Comments are closed.

Post Navigation