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
5
votes
4 answers

write results into a text file

I created a batch that will use windows FINDSTR to search for my selective input. I am trying to log my results of my search term in a text file called results.txt So I do have something like this so results are kept not overwritten: >>Results.txt…
Surfer Kyle
  • 71
  • 1
  • 1
  • 7
5
votes
3 answers

Search for string within filename in subdirectories

I have a large directory of folders (call it C:\Main). I need to set up a batch script to search the subfolders of that directory for a string within the filename (not the text within the file). I'm having trouble finding an answer. Essentially,…
Ikarian
  • 51
  • 2
  • 2
  • 4
5
votes
3 answers

how to read a file from line x to line y (dos/win batch file)

I have a series of log files. I parse these log files with findstr to determine the first instance of a string of text, then return the file name and the line lumber the match was found on as variables. I then use findstr to parse the file the match…
user1851547
  • 51
  • 1
  • 3
5
votes
2 answers

Use subpatterns in FINDSTR

I must check the validity of a string stored in a variable, I can not use external CLI utilities (grep, awk, etc.) so I chose FINDSTR. The string has this format (in regexp): ([1-9][0-9]*:".*"(|".*")*) I do not know how to check the subpattern (|.…
networkcode
  • 53
  • 1
  • 3
5
votes
1 answer

Search and then delete depending on whether files contain a string

I'd like to search through multiple text files in a single directory for a string ('monkey'), if the string exists, then either, depending on what's easiest: rename the matching string - e.g. change monkey monkey1 and save then file and carry on…
user1585297
  • 51
  • 1
  • 2
4
votes
2 answers

Search in all directories

I can't find out how to search in Vim in all directories with: grep ack findstring vimgrep p.e. search "search-item" in all .txt files in c:\ and d:\ (including sub directories) Can anyone help me?
Reman
  • 7,931
  • 11
  • 55
  • 97
4
votes
2 answers

grep like syntax with findstr

ive been using grep a lot on linux lately but now i need to use findstr to carry out the same tasks on a windows machine and cant quite get the syntax just right. My grep command looks like: grep "12/12/2011.\*followed by literal string"…
bobbyrne01
  • 6,295
  • 19
  • 80
  • 150
4
votes
2 answers

GitLab runner on Windows and dealing with & %ERRORLEVEL%

In my .gitlab-ci.yml, i am trying to use the findstr command. findstr /c:"%SOLUTION_DIR%" gitlab.dif > founded.ref This command set the %ERRORLEVEL% to 1 if it has no match of "%SOLUTION_DIR%" in gitlab.dif. It seems like GitLab runner is…
jBravo
  • 873
  • 1
  • 9
  • 28
4
votes
1 answer

Escaping exclamation marks with delayed expansion

I have a batch file I'm using to search for a piece of text and replace it with another. It works, but what's happening is that when the 'new' file is created, anything after an exclamation mark is deleted. So original file Hello! I have some…
SwagBag
  • 43
  • 2
4
votes
1 answer

DOS Command FindStr

I have a need to use the DOS command FINDSTR to search in all our source code files mixed with other types of files such as PDF, exe, dll, etc. I do not need to search those binary files. Is there a way to exclude binary files? My command looks…
John
  • 691
  • 1
  • 8
  • 23
4
votes
2 answers

findstr query including tab character

I'm trying to use findstr in place of grep on a barebones vanilla windows box (which is sadly a requirement). I have some relatively large files (1Gb+), and I would like to extract those lines which don't include MX, MXnn, BR, and BRnn delimited by…
Dycey
  • 4,767
  • 5
  • 47
  • 86
4
votes
2 answers

findstr cannot use start and end of line

I don't get it; the FINDSTR usage is clear, but I can't get it to work. I want to FINDSTR on a text file, using the ^ and the $ character. This way: findstr /C:"^test$" test.txt I have made the file (test.txt) in several ways (all on Windows), and…
tvCa
  • 796
  • 6
  • 13
4
votes
1 answer

(' findstr /b "URL=" "%~1" ') not working with ö,ä,ü in path or filename

I want to search "URL=" in a file. As I am quite a noob in such things I collected some code snippets from stackoverflow, ... ;-) http://www.dostips.com/forum/viewtopic.php?f=3&t=2836&start=30 Get list of passed arguments in Windows batch script…
ggggg
  • 41
  • 5
4
votes
3 answers

How to delete the first line of a file using Batch?

How to delete the first line of a file using Batch? I really need help... I've tried everything but it didn't work. :( I've tried this : @echo off Type test.txt | findstr /I /V /C:"So, lets remove this line" >>Test2.txt exit
Login
  • 143
  • 1
  • 1
  • 11
4
votes
2 answers

grep in windows batch file

I am trying to write a Windows batch file that will look through a specific html index file that looks something like this (simplified) Emergency Calls
Emergency Calls
Steve Cohen
  • 4,679
  • 9
  • 51
  • 89
1 2
3
48 49