0

guys if I want like do findstr many time it just don't show the value of 2 & 3 in the line please correct me

>summary.txt (
  for %%F in (*chkpackage*) do findstr %1 "%%F" nul || echo %%F:N/A  && findstr %2 "%%F"  &findstr %3 "%%F"
)

I want to search on the string 2 and 3 too but why after I run this string 2 and 3 don't show

Did i use some syntax wrong?

like if in my resource text file have "

aaa 111 
bbb 222 
ccc 333 
DDD 444 
eee 555 
aaa 666 

sting1 for aaa
sting2 for ccc
sting3 for eee

result in summary.txt would be like

filename.txt : aaa 111 : ccc 333 : eee 555 
filename.txt : aaa 666 : ccc 333 : eee 555

Thank you for any answer

13
  • 1
    Thank you for providing the expected output. But what is the corresponding input and what are the search terms you would be using to try to get the specified output? Commented Feb 18, 2013 at 7:50
  • input is like abc.abc for string1 & 2 & 3 i just want to find the line that contain this 3 word and sum it then write to text file for later use in my excel( i used it with VBA) Commented Feb 18, 2013 at 8:00
  • What kind of logic are you trying to implement with the multiple FINDSTR calls? Is it string1 AND string2 AND string3 or string1 OR string2 OR string3 or something else, perhaps? It seems like ANDs all the way, but I'm not sure, even less so since you are saying it's not working as expected. Commented Feb 18, 2013 at 8:03
  • Oops, you seem to have answered my question while I was writing it. So it's ANDs, right? I.e. it should be the line(s) containing all three of the terms, correct? Commented Feb 18, 2013 at 8:05
  • 1
    Yes, I thought at first that you wanted one line that contained all three arguments. Commented Feb 18, 2013 at 9:00

1 Answer 1

1

Perhaps is this what you want?

@echo off
for %%F in (*chkpackage*) do (
   for /F "delims=" %%a in ('findstr %1 "%%F"') do (
      for /F "delims=" %%b in ('findstr %2 "%%F"') do (
         for /F "delims=" %%c in ('findstr %3 "%%F"') do (
            echo %%F : %%a : %%b : %%c
         )
      )
   )
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.