Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Poll

how to find a string (including quotes) in dos

na
1 (50%)
na
1 (50%)

Total Members Voted: 2

Author Topic: want to search a string including quotes in DOS  (Read 9395 times)

0 Members and 1 Guest are viewing this topic.

nelaps

  • Guest
want to search a string including quotes in DOS
« on: February 03, 2010, 12:20:28 PM »
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

BillRichardson



    Intermediate

    Thanked: 15
    Re: want to search a string including quotes in DOS
    « Reply #1 on: February 03, 2010, 09:10:31 PM »


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

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

    C:\batch>
    Bill Richardson

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: want to search a string including quotes in DOS
    « Reply #2 on: February 03, 2010, 09:17:54 PM »
    you need to escape the quotes:

    for example:

    Code: [Select]
    findstr "\"80\"" file1.txt
    I was trying to dereference Null Pointers before it was cool.

    BillRichardson



      Intermediate

      Thanked: 15
      Re: want to search a string including quotes in DOS
      « Reply #3 on: February 04, 2010, 03:22:25 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>
      « Last Edit: February 04, 2010, 04:00:58 PM by BillRichardson »
      Bill Richardson