1.   Filter a result

#Linux

$ ls -ls | grep mkyong

 

#Windows

c:\>dir | findstr mkyong

2.   Search a File

#Linux
$grep mkyong test.txt
 
#Windows
c:\>findstr mkyong test.txt

3.   Counting the number of matches

#Linux
$grep -c mkyong test.txt
 
#Windows -Piped with find /c command.
c:\>findstr -N "mkyong" test.txt | find /c ":"

4.   Search a list of files

#Linux
$grep mkyong -lr /path/folder
 
#Windows
c:\>findstr /M mkyong c:\folder\*

5.   Help

#Linux
$grep --help
$man grep
 
#Windows
c:\>findstr -?

6.   Finds the line number and highlights it with green lettering on a pink background -A:DA

#Windows
c:\>findstr -N -A:DA "mkyong" test.txt

7.   Finds the line number and highlights it with green lettering with default background -A:A

#Windows
c:\>findstr -N -A:A "mkyong" test.txt

 

 

References

http://www.mkyong.com/linux/grep-for-windows-findstr-example/