Questions tagged [findstr]

findstr is a Windows command that searches for patterns of text in one or more files using regular expressions.

Useful links:

  1. FINDSTR on technet.
  2. FINDSTR on SS64 help pages.
730 questions
2
votes
2 answers

Better way to use findstr to get packet loss, batch

Looking to use findstr to get it to find "0% loss" after a ping command. Perhaps an array of anything up to "50% loss". This is for checking and ensuring a connection to the internet is 100% established before launching something online. Currently…
Cinn
  • 71
  • 1
  • 11
2
votes
2 answers

batch: ampersand causing issues with findstr

This part works well until there is an ampersand in the filename, in which case it crashes my script completely. echo %filename% | findstr /i /b /c:"%name% (%year%)" I can't just put the filename into quotation marks because I need to find the…
Bricktop
  • 533
  • 3
  • 22
2
votes
1 answer

Error "| was unexpected at this time."

I am using code as below to delete program using port 8080, but I got error | was unexpected at this time., what can I do? FOR /F "tokens=5 delims= " %P IN ('netstat -a -n -o | findstr :8080') DO TaskKill.exe /PID %P
mikezang
  • 2,291
  • 7
  • 32
  • 56
2
votes
1 answer

findstr does not find "NOW"

I don't have a lot of experiences with findstr but this is not understandable for me at all. Or is it a bug of findstr? look at these examples: 1) echo NOW|findstr "CLEAN NOCHANGE NOW">NUL&&echo found return nothing But why?? 2) echo CLEAN|findstr…
laza
  • 91
  • 7
2
votes
2 answers

Search for string in all files in current drive using regex on windows

I am trying to search for an email address on my harddisk. I know that it should be something like: b************m@e******.com and this is why I came up with this regex: b.{12}m@e.{6}.com I found that findstr could be useful for this job and…
asknomore
  • 31
  • 1
  • 5
2
votes
2 answers

Using Findstr with specific range or other method

I only want to find specific lines in his text file, so i figure that using range would be a good idea. But i can seem to find any tutorial online. please help.. An example of the text file XXX scan report for…
Ivan Sim
  • 305
  • 4
  • 15
2
votes
1 answer

Batch file to find a file using regular expression and rename it

@echo cd\ cd C:\Test\pdf for /f "delims=" %%i in ('dir /b | findstr /E /R "\\BW RRI - [0-9]\.[0-9]\PAYMENT CONFIRMATION.pdf$"') do set "Filename=%%i" ren ("%FileName%" "test.pdf") EXIT So i am trying to run above batch to find a file and…
PPrat
  • 39
  • 4
2
votes
1 answer

Ridiculous caret escape sequence when mixing FOR and FINDSTR

I've got a string verification batch that handles rudimentary regex with FINDSTR and almost called it quits today when I thought I was unable to properly escape the caret character until I added a over a dozen ^. Fail-verification Command:…
kayleeFrye_onDeck
  • 6,648
  • 5
  • 69
  • 80
2
votes
1 answer

Why do I have to escape my already escaped search string in a for loop in a batch file?

After trawling through S.O. I've managed to piece together my function so it works, but I don't understand something about it. I'm basically trying to ensure that a file I want to use doesn't have double quotes in it. I've used findstr with the /m…
Andy Moss
  • 23
  • 3
2
votes
3 answers

How to run combined findstr script

Hi I have a script I made using information on this page. I realize that running two separate batch files (:SetVarand:Brains) will work but when I try to combine the two into one It doesn't work. I'd be happy if anyone can explain to me why mine…
MALKAVIAN
  • 131
  • 14
2
votes
1 answer

Batch file to print first match of findstr results only to text file

Im trying to write a batch file that reads a list from fileA.txt then checks fileC.txt if match exists, if match not exist write first matching line only from fileB.txt to fileC.txt fileA.txt example aaa1 aaaa aaaa4 bbb ccc12 fileB.txt example aaa1…
dragon_sa
  • 49
  • 1
  • 6
2
votes
1 answer

How to use cmd to save string and the output of findstr together?

(Platform: Win7) I am able to directly save the output of what "findstr" command find. findstr /S /N "#ifdef" *.cpp >D:\Test\123.txt and the output looks like this: dealloc.cpp:3:#ifdef 1 But I just can't to make it save in the format like file…
Heidi
  • 31
  • 1
  • 4
2
votes
0 answers

Result from 'findstr /G:' not complete, comparing to 'grep -f'

I have to look up a list of thousands of gene names (genelist.txt, one column) in a database file called (database.txt, multiple columns). Any lines containing at least one gene name that match the genelist.txt will be extract to output.txt. I used…
Nengchi Te
  • 61
  • 5
2
votes
1 answer

How can a batch program parse a text data file for values and then save into a csv type file?

I have a bunch a raw data that really only has four values I care about: DX, DY, Width and Height in addition to the corresponding offset name. The text file with this raw data looks like this: 0:walk: Length=5 Offset=#b0 U1=#1058000 U2=#ff U3=#0…
2
votes
1 answer

How to use findstr to get MAC address?

I send adb shell dumpsys wifi to get current available wifi ap BSSID(MAC address).The result as follows: Latest scan results: BSSID Frequency RSSI Age SSID Flags 7c:7d:3d:c3:4c:e0 …
jiajia guo
  • 332
  • 2
  • 3
  • 16