Checking Log Files

Since you were kind enough to advertise my diagnostic tool, I thought you
might also like another quick and dirty one which I've put together.
Someone wanted to check (text) log files for the last occurrence of an
event, which was reported a few lines after the trigger event. The attached
program scans through a number of files, finds a specific string, then
outputs a specified number of lines to another file. If you understood
that, you're doing well. You could probably use grep, but writing this was
probably quicker than working out grep's syntax.

It is a 32-bit Windows command line program with the following syntax:

lineget.exe [-a] [-lx] [-mx] [-vx]
where

infilespec is the file specification of files to be acted onoutfilename is the file where the results are to be stored[-a] output all occurances of the search string (default last)[-lx] where x is line number after the search string to commence (default
0)[-mx] where is is the number of lines to return (default 1)-sx where x is the string to search for[-vx] level of reporting (default none)

Thus if you want to search all *.txt files in a subdirectory for the last
occurrence of "search string" and return the fifth through tenth lines
following "search string" and output the result to a file called
"fred.txt", you would use:

lineget *.txt fred.txt -l5 -m1 -s"search string"

I should warn you that some of its limitations are that

lines in the log/text files must be less than 1024 characters;

parsing and error handling are very basic or non-existent so parameters
should be separated by white space

There probably are other limitations, but I can't think of them off the top
of my head.

If you think that it shows promise, but needs improving, please let me
know at

victor.markwart@centrelink.gov.au.

If there's any interest I could include things such as the ability to recurse up sub-directories, better output options, such as converting to csv or tsv from standard text files. Source code is available on a PNTL license (Promise Not To Laugh).