Solved

Search Batch file

Posted on 2004-04-29
10
1,469 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 67

Expert Comment

by:sirbounty
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 3

Expert Comment

by:CoolBreeze
Comment Utility
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
Comment Utility

 
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
Comment Utility
Kavar

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

Expert Comment

by:kar10s
Comment Utility
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
Comment Utility
uff , too slow
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Windows 10 SmartScreen vs ClickOnce app 5 132
dividesSelf challange 15 77
countHi challenge 25 84
python question 5 57
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
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 …

743 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

18 Experts available now in Live!

Get 1:1 Help Now