|
|
|||||||
Hi, I'm looking to parse a log file for lines of text, I'm used to using grep in linux, eg >>>cat file.txt|grep "started"<<< This would echo the lines with this string to the screen, I would like to extract these details and send them to a text file. Is there anything similar in kixtart Darren |
||||||||
|
|
|||||||
READLINE() to parse the file and INSTR() to search for your selected text. Code: Open (1,"somefile.txt",2) Open (2,"output.txt",5) $R=Readline(1) While @Error = 0 If INStr($R,"Looking") Writeline(2,$R+@CRLF) EndIf $R = Readline(1) Loop Close(1) Close(2) |
||||||||
|
|
|||||||
If you did not want to walk through the file using READLINE, then you would have to use an external tool such as FIND.EXE (part of windows) or Regular Expressions COM object. |
||||||||
|
|
|||||||
Ok, Tried that and it did not seem to work? in the mean time created this using the pipe function Open (2,$logpath+"outputmine.txt",5) $array = pipe('type '+$file+' |find "started"') For Each $file In $array Writeline(2,$file+@CRLF)? Next Close(2) does the trick... Darren |