Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript using the find command

Status
Not open for further replies.

NetworkGhost

IS-IT--Management
Joined
Apr 12, 2005
Messages
1,324
Location
US
What i am trying to do is us the DOS Find command to search trhoguh some log files. That workes great. What I would really like is once I get a line match on my search string is to pull 2 lines above an 7 lines below. So if I was seraching for the word cat in a log file I would get:


dog
bird
cat
chicken
chicken
chicken
chicken
chicken
chicken
chicken

Is there a way to do this with VB script?
 
yes, read the file contents into memory...array or counter indexed dic object, that way you can then traverse backwards
 
Yeah, did I mention I suck at VBscript? I understand loops and stuff but not in VB. I downloaded grep for windows and used that. Worked like a charm. Thanks. If you want to post an example Ill give a star.
 
That looks like a start but how would I integrade the find command on a file that exists and then grab 2 lines above and below the target? with grep I can do:

grep -B 2 -A 2

I would like to do this in a script.
 
there is no built in command in vbscript to due this, generally it is seen as a scripting language, grep is an exe file. one would need to right an alga in vbscript to accomplish this, see it as a challenge and a fun task to do...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top