Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Counting Specific words in a Text/log file

$
0
0
Hi all,

I've been playing around with trying to get a script to do a count of words in an active log file... I want it to count two specific strings, then do a calculation on those strings to produce a result.

For instance;

Read C:\log.txt for the words "system is up" and "system is down"...

Add the string "system is up" to $up variable, and "system is down" to $down variable.

Once that is done, a calculation will be made to determine if $down equals the same or more than $up, and output this the result such as "System is Down" or "System is running as normal" to a HTML file.

I've coded pieces of this, but just can't get it working and wondered if someone may be able to assist with some code to do this more simply?

Viewing all articles
Browse latest Browse all 21975

Trending Articles