4

i'm trying to find a word in a CMD command output (like using ctrl+f in a file) the output contains a lot of lines ...

Any hints ? thanks .

1
  • What is "ctrl+f in a file"? Looking for findstr? Commented Jan 19, 2016 at 22:46

2 Answers 2

4
find "yourword" filename

to show your word in any line of a file.

yourcommandgivingsoneoutput | find "yourword"

to examine the output of some command for your word.

If you just want to see whether your word ixists in the data, then append >nul to the line to suppress output and on the next line of (presumably) your batch use

if errorlevel 1 (echo word missing) else (echo word found)

There are many options which you can invoke - use

find /?

from the prompt for documentation.

findstr is similar, and allows searching for multiple words and has a restricted regex implementation.

findstr /?

from the prompt for documentation.

2
  • 1
    that was exactly what i'm looking for yourcommandgivingsoneoutput | find "yourword"
    – The Beast
    Commented Jan 20, 2016 at 1:53
  • The question is about searching the existing text output on the window (possibly the concatenation of output from several other commands). The provided answers DO NOT address the asked question. Commented Oct 21, 2022 at 14:24
2

actually, you didn't get the concept because in fact you want to search in a " program" while you can search in "files" ...

CMD, git-bash or any other terminal is not a file like a text file or word document or any other type of files so searching in terminals has no meaning as it's nonsense if you want to search in "clash of clans" !!

but you can search in the output of any command and there are many ways for this, for Example, we can search in the output of dir command:

1- #>dir | find "search_word" → will find any output which is Exactly like your search_word

2- #>dir *search_word* → will find any output that contain your search_word

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.