Questions tagged [findstr]

Use this for question about the DOS/cmd findstr command for searching for strings in files

findstr is a utility from DOS or cmd/command.com that will search for strings within files, similar to grep.

A simple example, to find lines that contain the string ID from a file named errors.txt would be

findstr ID errors.txt
77 questions
40
votes
4 answers

findstr DOS Command's multiple string argument

findstr /v "black" File1.txt Above DOS command will display content of 'File1.txt' which are not matching string "black". How to modify this command , if I need to filter words "black" and "white" ?
Arun
  • 565
36
votes
6 answers

What's the difference between the find and findstr commands in Windows?

In Windows, what are the differences between the find and findstr commands? Both seem to search for text in files: find C:\> find /? Searches for a text string in a file or files. FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string"…
8
votes
3 answers

FINDSTR: Line is too long

Windows FINDSTR command is useful for sifting through large amounts of data; it filters out lines of text that match or don't match a specified pattern or string (like GNU/BSD grep). But it refuses to output lines longer than a certain length. Is…
voices
  • 2,881
7
votes
5 answers

How do I extract the IPv4 IP Address from the output of ipconfig

I'm attempting to have cmd copy only a specific set of character from a command output. I've been able to select the line that the phrase exists in but from there I am lost. Here is my command so far. ipconfig | findstr /i "ipv4" I'm sure you are…
6
votes
4 answers

Using 'ping' and 'findstr' in a 'for' loop of batch file first throws error not an internal external command but it again shows output

This batch file @echo off set path=C:\Users\ssiyengar\Desktop\Pingtest\pinglist.csv set file=C:\Users\ssiyengar\Desktop\Pingtest\temp.txt set qosping=1 cls for /f "tokens=1-3 delims=," %%a IN (%path%) do ( ping %%c -n %qosping% > %file% …
6
votes
1 answer

Use findstr to Search a Sub Directory for a String?

I can use the following to search for text files that contain the word "string" from the Windows Command Prompt: C:\>findstr /spin /c:"string" *.txt What if I want to search a sub-directory? The following doesn't work: C:\>findstr /spin…
GTS Joe
  • 281
5
votes
1 answer

Vim: How do you use external grep on windows to search for quotation marks?

For some reason I can't for the life of me figure out how to pass single quotation marks to external tools when using vim. For example, I might want to call Vim's external grep to search for the text "foo (that is, a single quotation mark then the…
5
votes
2 answers

Is there a better way to mitigate this obscure color bug when piping to FINDSTR inside a parenthesized block of (.bat) code?

In the following .BAT file, test 2 demonstrates the color bug inside a parenthesized block of code, test 3 demonstrates the bug inside a FOR loop, and test 4 shows how the bug can be mitigated by calling a do-nothing subroutine (call :resetANSI). …
3
votes
3 answers

In windows, is there a way to count the amount of times a string appears in a file

I am currently trying to write a batch script and at this point, I need to find a string, "null", and determine how many times it is shown in the file. I'm downloading an API from a website every-time that the script starts and within their API they…
3
votes
2 answers

findstr /X keeps printing lines with no matches

I'm using nslookup and findstr in a simple batch script to check if a website is up. However findstr keeps printing lines which doesn't contain any matches. The command goes like this: nslookup goofdedwsgle.com | findstr /X /C:"Non-existent…
Mizuki
  • 33
3
votes
0 answers

find string from multiple files and replace it without creating new file

I want to find string e.g. "date" from my files of a folder which contains multiple ".c" and ".h" files in it and replace it with "date 24-April-2018" using batch file. what should do? Please see below code. I want to do the same but not for one…
Meera
  • 31
3
votes
2 answers

A powershell version of for /f (|findstr) for Unicode folders/files

Here is a small script I wrote that recursively scan a directory without some parent-subdirectories and extracts some attributes of the files within it. @echo off echo Path,Name,Extension,Size > filelist.txt for /f "delims=" %%i in ('dir D:\שער…
2
votes
1 answer

Get URL from HTML file using FindStr

I'd like to preface this by saying that I'm very new to the command prompt and I've been only using it for some WGET and YOUTUBE-DL, and that I'm on a Windows 8 PC. I'd like to get a bunch of links from an html file. The links all start…
user458779
2
votes
2 answers

Most efficient command to search the first line of many files (windows)

I am new to the windows ecosystem. I have been tasked with writing a program that will search several 10's (maybe even 100's) of thousands of files for a particular string. The string that must be matched is a serial number consisting of only…
tpdietz
  • 121
2
votes
1 answer

Delete scheduled taskname containing space

I want to delete scheduled tasks that start with "Adobe Acrobat" eg "Adobe Acrobat 123","Adobe Acrobat 456","Adobe Acrobat 789" schtasks /Delete /TN Adobe* /F This command fails to find any tasks cos its literally searching for the taskname…
eureka
  • 143
1
2 3 4 5 6