Questions tagged [findstr]

9 questions
11
votes
3 answers

Doing logical OR comparisons with findstr.exe

This may be a stupid question but even after reading the documentation I'm still not sure how to find all lines in a file that contain either ".cpp" or ".h". Is there a way to do that? For example (doesn't work): findstr /i .cpp,.h // , == OR
Andreas Bonini
  • 1,292
  • 1
  • 9
  • 16
3
votes
2 answers

How can I escape double quote character for use in findstr on the PowerShell command line?

This command lines works running in cmd.exe: findstr /l /i /s /c:"key=\"Smtp" *.config However running in PowerShell 2 on Windows 7 Ultimate x64, findstr seems to freeze no matter which combination I use. I am searching a toy file I created (only…
ZeroBugBounce
  • 133
  • 1
  • 1
  • 4
2
votes
1 answer

Search strings in text files and show in output the string, preceding one and next one (cmd.exe)

I have a lot of big text files. And I'm searching (within cmd.exe) for a list of values in them as following: findstr /i /n /g:strings.txt 1\*.* >results.txt where strings.txt is the file with all the values I'm looking for and 1 is a folder where…
2
votes
5 answers

Windows Batch - Get name of currently logged-in user

In a sort of small mitigation for a large network for the exploit of replacing utilman.exe on windows repair, by cmd.exe, then changing user password, I'm doing a small script based on EventSentry tool that will detect that utilman.exe is changed…
DefToneR
  • 461
  • 5
  • 12
1
vote
1 answer

Windows findstr with AND condition?

Is it possible, in one line, without a batch file to use findstr and only return a 0 %errorlevel% if all of the strings are found? I am doing a gem list, which lists out a bunch of gems. I then want to use findstr/find to make sure that EACH string…
tek0011
  • 21
  • 4
1
vote
5 answers

Copying a chunk of output in Windows 7

I'm wondering how to copy a chunk of output in the command prompt in Windows 7. What I'm ultimately trying to accomplish is when I type "route print" I want to copy the IPs listed under IPv4 Route Table. I used the findstr command to grab 1 line…
syuusuke
  • 93
  • 8
0
votes
1 answer

How to remove a line in a file found in multiple directories

There is file that exists in each user profile directory and I need to remove the line from the file in each user profile directory. I'm using a batch script to go through each user profile directory, type the file, use findstr to not display the…
hsatterwhite
  • 322
  • 2
  • 5
  • 14
0
votes
1 answer

Matching Inverse of String in Windows CLI

Can anyone show me a good example of how to match it. Maybe I misread the documentation a bunch of times, but it does not even some close to how real tools like grep ought to work. The output of the following command, wmic /output:stdout csproduct…
songei2f
  • 1,924
  • 1
  • 20
  • 30
0
votes
0 answers

BAT script to return server licenses at shutdown?

My office uses program licenses that have to be manually activated and returned, and people tend to forget to do this when they go home for the day, resulting in most licenses tending to be unavailible for anyone coming in early next morning and…