Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Search Batch file

Posted on 2004-04-29
10
Medium Priority
?
1,516 Views
Last Modified: 2010-08-05
Hi im using this to search a file for the word hotfix..


type C:\lab\tempRegistryextract.txt|findstr -i "hotfix" > C:\Lab\%Computername%.txt


however i would like to be able to now search for lines which contain "XPQ  i need to include the " in the search, how can i do this ?
0
Comment
Question by:gisvpn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +3
10 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 10949558
I don't follow you exactly.
You need to find both hotfix and XPQ? in the same line?

type c:\lab\tempRegistryextraxt.txt|find /i "hotfix"|find /i "XPQ" >> C:\lab\%computername%.txt
0
 

Author Comment

by:gisvpn
ID: 10949724
i need to search for the actual string "XPQ i would like the " included as the string it searches
0
 
LVL 3

Expert Comment

by:CoolBreeze
ID: 10949755
I think he wants to search for the word "XPQ
where the double quote is insert the search string.

I think you can 'escape' the double quote by using a backslash. i.e.
find "\"XPQ"
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 67

Expert Comment

by:sirbounty
ID: 10949834
I don't think you can escape it with \ or ^....
See this PAQ - it explains a way around it: http:Q_20566636.html
0
 
LVL 11

Accepted Solution

by:
griessh earned 2000 total points
ID: 10949925
Hi gisvpn,

You can do what CoolBreeze said:

type C:\lab\tempRegistryextract.txt|findstr /i \"XPQ > C:\Lab\%Computername%.txt

You only need the quotes around your search string if that string contains separators like blanks. In your case "\"XPQ" will have the same search results as \"XPQ

You don't have to pipe the text file into findstr either.

findstr /i \"XPQ C:\lab\tempRegistryextract.txt > C:\Lab\%Computername%.txt

will do what you want:-)

Run "help findstr" in a command window and it will tell you:

  \x       Escape: literal use of metacharacter x

and

FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F:file]
        [/C:string] [/G:file] [/D:dir list] [/A:color attributes]
        [strings] [[drive:][path]filename[ ...]]

======
Werner
0
 
LVL 3

Expert Comment

by:CoolBreeze
ID: 10950059
what a mistake i made, I actually meant findstr, not find. the escape character is for findstr.
for find, maybe you can try " as the escape character. i.e. """XPQ"
0
 
LVL 10

Expert Comment

by:Kavar
ID: 10950067

 
gisvpn , you still messing with this batch stuff for searching the registry?? When am I going to convince you that there is a MUCH better way??
0
 

Author Comment

by:gisvpn
ID: 10950094
Kavar

haahhaahahah - this is a project im just finishing ! Lots more coming !
0
 
LVL 3

Expert Comment

by:kar10s
ID: 10950157
Hi,

type c:\lab\tempRegistryextraxt.txt|find  "hotfix"|find """XPQ" >> C:\lab\%computername%.txt

above line will find all the lines that contain both the word hotfix and "XPQ
I have eliminated /i parameter to difference between capital and small letter( nor Hotfix or "xpq ..)
Observe use of 3 " to find "XPQ
Regards
0
 
LVL 3

Expert Comment

by:kar10s
ID: 10950197
uff , too slow
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question