Grep with special Characters

Need Help For GREP

I have a file say g1.txt and content of file is below

REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoDrives /t REG_DWORD /d 4 /f ,
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoClose /t REG_DWORD /d 1 /f ,
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v NoDispCPL /t REG_DWORD /d 1 /f ,
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explore\HideDesktopIcons\NewStartPanel" /v {20D04FE0-3AEA-1069-A2D8-08002B30309D} /t REG_DWORD /d 0 /f , 
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v DisallowRun /t REG_DWORD /d 1 /f , 
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Uninstall" /v NoAddRemovePrograms /t REG_DWORD /d1 /f ,

I want to check the string

"REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoDrives /t REG_DWORD /d 4 /f" already exists or not in g1.txt file...using grep command..
grep '"REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoDrives /t REG_DWORD /d 4 /f" ' filename

will give you the line at which this pattern was found

if u want to find the no of times this string occured use -c option

grep -c searchstring filename

thanks,
venkat

It's not working.....String containing special characters like ",{,\" so that it could not find the match

Try this,

grep 'REG ADD \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\" \/v NoDrives \/t REG_DWORD \/d 4 \/f' filename

if you specify anything within single quotes doesn't matter even the special characters will be treated as a character only

did you tried that ?

---------- Post updated at 06:00 PM ---------- Previous update was at 05:59 PM ----------

see this example

$ grep '<dir>' *
file.xml:       <dir>
file.xml:       <dir>
file.xml:       <dir>
file.xml:       <dir>
script.sh:    echo -e "\t<dir>" >> file.xml