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
3
votes
2 answers

How should I find all the files that contains two strings?

My problem is to create a batch script file for Windows and iterate through a lot of files and find every file which has a line that contains two specified strings. So if the whole file contains those strings, that's not good enough, they should be…
fzl
  • 171
  • 2
  • 10
3
votes
3 answers

What is the location of FINDSTR on all Windows OS from Windows XP to Windows server 2012?

Is the directory of findstr always C:\Windows\system32\ for all OS from Windows XP to server 2012? Or in other words is it safe to replace the following expression in a windows batch file: findstr to C:\Windows\system32\findstr
Brainless
  • 1,522
  • 1
  • 16
  • 30
3
votes
1 answer

Batch file - How to use FindStr with percent

I have a batch file with the following header: @Echo off SETLOCAL EnableDelayedExpansion EnableExtensions Within a If statement, enclosed in parenthesis (), I have the following code: Echo SOME_VAR|FindStr /r /C:"^.*SOME.*$" Echo Error:…
jeremfg
  • 323
  • 2
  • 8
3
votes
4 answers

Windows CMD: How to pipe running program output to FINDSTR and write to file

I am trying to filter the output of a running program (ping) and write the results to a file. In the following example the ping program runs until CTRL-C is pressed: ping www.google.com -t | findstr "Reply" >> file.txt the result of this is the…
jakob
  • 35
  • 1
  • 1
  • 5
3
votes
3 answers

Adding specific letters to a string MATLAB

I'm a neuroscience/biomedical engineering major struggling with this whole MATLAB programming ordeal and so far, this website is the best teacher available to me right now. I am currently having trouble with one of my HW problems. What I need to do…
Jessica Marie
  • 293
  • 5
  • 16
3
votes
2 answers

How to search for a string in a file and copy found line and next line to another file?

I have 2 lines in a file called database.txt. One line contains a question, and the consecutive line below contains the answer. For example: <--When did India get it's Independence?--> India got it's independence on August 15th, 1947. If user…
blah
  • 103
  • 3
  • 12
3
votes
4 answers

Batch, comparing two files and write differences to another file

I've searched for solution but I still have problems with it. I have two files: File1.txt 1111 2222 3333 File2.txt 1111 2222 3333 4444 and I want an output file with only differences: File3.txt 4444 I've tried using Findstr but it doesn't…
user3151135
  • 35
  • 1
  • 5
3
votes
4 answers

IP verification in batch script - first match by findstr, secondly verify by for loops (only using windows built in functinallity?

This is a question for the batch pro's i guess. Seems a lot of people do stumble over IP veriffication while batching, while just using windows built in functinallity, but no real code is to find. At several places a findstr expression is findable,…
peet
  • 274
  • 3
  • 5
  • 18
3
votes
4 answers

How to use findstr, exclude svn directory in gvim

I want to find out all the files which contain a keyword in a directory and all the subdirectories, and there are some .svn directories, I should ingore these directories. In Linux system, I can do it easily by: grep -r keyword ./ --exclude-dir…
srain
  • 8,944
  • 6
  • 30
  • 42
3
votes
2 answers

Return previous line with Findstr

I am running FINDSTR command to find specific text in .txt files. I want to print matching lines as well as 1 previous line. findstr "ActualStartDate:" * > a.txt if my file is like this abcd defg cds ActualStartDate: invalid date Result…
user0404
  • 113
  • 3
  • 14
3
votes
5 answers

delete tab at the end of each line of a file

To delete tab at the end of each line of a text file, I do findstr /r /v /c:"[ ]$" "~1">result.txt But tab is still there. a file example John Doe Bob Materson .......... After John Doe, Bob Materson, ..., it may have some tab. I want to…
new
  • 1,109
  • 5
  • 21
  • 30
3
votes
1 answer

One type with two findstr (and pipe output)

I have 50 files named like: CPUNAME_installer.txt and the content of each is something like: CPUNAME;11724;sdaasdasdasdasdasdasd CPUNAME;1034;231asddasd CPUNAME;1035;231asddasd CPUNAME;10741;231asddasd CPUNAME;10111;231asddasd ...and so on, for…
HS_PT
  • 33
  • 1
  • 3
2
votes
1 answer

Tasklist for remote machine and Findstr passing a exit code

I am trying to search for a process on a remote machine and pass an exit code so it can be handled by another process. So if the process exists output exit code 1, if not do nothing. I wrote the script below with some help from another post. It…
Kay
  • 23
  • 4
2
votes
1 answer

What is the difference between find and findstr in Windows CMD?

find /? prints: Searches for a text string in a file or files. and findstr /? prints: Searches for strings in files. What is the difference between these two?
Giorgi Tsiklauri
  • 9,715
  • 8
  • 45
  • 66
2
votes
0 answers

How to write a Windows batch script that uses findstr to search a file for a string that contains quotes, spaces, and colon

I'm attempting to write a batch script that searches a file using findstr for the following string: "jobType" : "upgrade_application" Appreciate any assistance. I've tried several variations of the following: findstr /C:""jobType" :…
Brian
  • 319
  • 1
  • 5
  • 13