Can I use FINDSTR to move selected text from a file and move to another ?

I have a log file that I want to split into multiple files based on text inside the file.
For example, this log file is concatenated throughout the day, but our client would like pieces of the log as the are generated.
The good thing is that each line begins with timestamp so it looks something like this:
08:15:49   Group Totals Record at line . . .
08:15:49   Blah blah . . .
08:15:49   Number of Records at line # 3352 Blah blah . . .
08:15:50   End of Job.
10:30:07   Blah blah . . .
10:30:07   Blah blah . . .
10:30:08   Blah blah . . .

I would want to send the lines after 10:30:07 to another file.
Is this possible ?
Thanks in advance
MGray55Asked:
Who is Participating?
 
Arno KosterConnect With a Mentor Commented:
you can do the trick in plain batch as well...

try making a for loop which scans each line and then assigns this line to a variable, say %%A
with the delimeter set to : this means that the actual hour is represented in %%A, minutes in %%B and seconds in %%C.

with a simple if %%A GTR 10 clause you can then reroute the total line to a new file if neccessary

for help on "for", "if", and "gtr" statements just type help in a command box.
0
 
bjorn_rohlenCommented:
Install cygwin from redhat (free product) or get GREP free from Borland (or any other GREP implementation you wish to use, GREP is short for Gnu Regular ExPressions).

To do what you want, I.ex get all the "10"'s in a file,

grep "10:" infile >outfile

To get anything BUY the timestamps at 10:00 (inverse matching),

grep -v "10:" infile >outfile

Etc.. You get the idea, modify the examples to fit your needs :)

-Bjorn
0
 
joelleoConnect With a Mentor Commented:
Aloha MGray55.

Using findstr you should have no problems doing what you'd like.

findstr "^10:" logfile.txt > newlog.txt

would output any line that begins with 10: to newlog.txt. That would include anything that was logged between 10:00:00 and 10:59:59.

This is a simple thing to do, but it's a manual process. If your boss wants you to give out anything that's occurred within the hour this works great. it becomes a bit more difficult if you are looking for "anything after 10:00:00." If you know roughly the # of lines in the log file, you could even just do a tail -n to copy out just the last n lines of the file.

Good luck!

Joel
0
 
MGray55Author Commented:
My requirements have changed, but I should be able to figure out something similar with your answers.
This script is being run on a server where I cannot install any utilities or third party products. Your answers should let me do it through straight DOS.
0
All Courses

From novice to tech pro — start learning today.