1.

Solve : want to search a string including quotes in DOS?

Answer»

i want to find a string whcih is in quotes
eg:
file1.txt contains
asdfg "80"asdf
1233"80"12345
654380654

file2.txt contains
asdfg 80 asdf
123380 12345

my output should be
file1.txt  asdfg "80"asdf
file1.txt  1233"80"12345

i'm using below command but i'm getting following output
file1.txt  asdfg "80"asdf
file1.txt  1233"80"12345
file1.txt  654380654
file2.txt  asdfg 80 asdf
file2.txt  123380 12345

findstr /s /i  /c:""80""  C:\* > FindString-80-100-quotes.txt

please let me know how to find a string which is in quotes
thanks

C:\batch>findstr "80" quotefile.txt  |  sed 's/"//g'
 12338012345

C:\batch>type quotefile.txt
 1233"80"12345

C:\batch>you need to escape the quotes:

for example:

CODE: [Select]findstr "\"80\"" file1.txt
Quote from: nelaps on February 03, 2010, 12:20:28 PM

I want to find and CHANGE a string which is in quotes

Code: [Select]rem ECHO off
findstr "\"80\"" file1.txt


findstr "80" quotefile.txt  |  sed 's/"//g'


findstr "80" file1.txt  |  sed 's/"//g'
Output:

C:\batch>quotefind.bat

C:\batch>findstr "\"80\"" file1.txt
 1233"80"12345

C:\batch>findstr "80" quotefile.txt    | sed 's/"//g'
 12338012345

C:\batch>findstr "80" file1.txt    | sed 's/"//g'
 12338012345

C:\batch>

Input:


C:\batch>type file1.txt
 1233"80"12345

C:\batch>

_____________________________


C:\batch>type file1.txt
 1233"80"12345

C:\batch>findstr 80 file1.txt
 1233"80"12345

_______________________
C:\batch>grep  80  file1.txt
File file1.txt:
 1233"80"12345

C:\batch>grep  "80"  file1.txt
File file1.txt:
 1233"80"12345

C:\batch>


Discussion

No Comment Found