• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 48
  • Last Modified:

Search through files to find matching strings that do NOT contain a prefix

I have roughly 1000 files from a website on my local hard disk.  I want to determine if any of these files have:
http://localhost

Open in new window

on any line, except skip the ones that have:
comment="http://localhost

Open in new window


Thus, if there are any "HREF="http://localhost" entries, it would show up, or any "SRC="http://localhost", it would show up in the results.

Any easy way to do this?
0
Tim Titus
Asked:
Tim Titus
  • 3
  • 2
1 Solution
 
ozoCommented:
grep http://localhost files | grep -v 'comment="http://localhost'
1
 
Bill PrewCommented:
What O/S ?


»bp
0
 
Tim TitusCTOAuthor Commented:
Sorry, Windows 10.  I don't have grep.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Bill PrewCommented:
Here's an approach with FINDSTR, you may want to tweak the options a bit, but see if this is close to what you are looking for.  Open a command prompt window, CD to the folder where the files are, and then do:

findstr /n/c:"http://localhost" < *.* | findstr /v /c:"comment=\"http://localhost"

Open in new window



»bp
0
 
Tim TitusCTOAuthor Commented:
Perfect!  I didn't know findstr existed!  Thanks!
0
 
Bill PrewCommented:
Welcome, glad that helped.


»bp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now