Darren_W
(Hey THIS is FUN)
2007-10-31 01:36 PM
Kixtart Function similar to grep in unix?

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


Gargoyle
(MM club member)
2007-10-31 02:06 PM
Re: Kixtart Function similar to grep in unix?

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)



Howard Bullock
(KiX Supporter)
2007-10-31 02:17 PM
Re: Kixtart Function similar to grep in unix?

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.

Darren_W
(Hey THIS is FUN)
2007-10-31 02:21 PM
Re: Kixtart Function similar to grep in unix?

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