Page 1 of 1 1
Topic Options
#182126 - 2007-10-31 01:36 PM Kixtart Function similar to grep in unix?
Darren_W Offline
Hey THIS is FUN
*****

Registered: 2001-10-10
Posts: 208
Loc: Bristol, England
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
_________________________
I want to share something with you - the three sentences that will get you through life.
Number 1, 'cover for me.'
Number 2, 'oh, good idea, boss.'
Number 3, 'it was like that when I got here'.

Top
#182127 - 2007-10-31 02:06 PM Re: Kixtart Function similar to grep in unix? [Re: Darren_W]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
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)

_________________________
Today is the tomorrow you worried about yesterday.

Top
#182128 - 2007-10-31 02:17 PM Re: Kixtart Function similar to grep in unix? [Re: Gargoyle]
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
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.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#182129 - 2007-10-31 02:21 PM Re: Kixtart Function similar to grep in unix? [Re: Gargoyle]
Darren_W Offline
Hey THIS is FUN
*****

Registered: 2001-10-10
Posts: 208
Loc: Bristol, England
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


Edited by Darren_W (2007-11-02 05:00 PM)
_________________________
I want to share something with you - the three sentences that will get you through life.
Number 1, 'cover for me.'
Number 2, 'oh, good idea, boss.'
Number 3, 'it was like that when I got here'.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.138 seconds in which 0.071 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org