Solved

Search Batch file

Posted on 2004-04-29
10
1,488 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
  • 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Report events not being triggered 8 120
Magic Software info 18 130
base64 decode encode 12 132
VB.net and sql server 4 33
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
This article will show, step by step, how to integrate R code into a R Sweave document
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

815 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now