?
Solved

Search Batch file

Posted on 2004-04-29
10
Medium Priority
?
1,509 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
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 …
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 …
Suggested Courses

752 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