scsh-users
[Top] [All Lists]

Parsing hack

To: scsh@martigny.ai.mit.edu
Subject: Parsing hack
From: jbell@capecod.net (Janet Bell)
Date: Tue, 02 Jul 1996 04:38:59 GMT
I was attempting to parse apache logs with scsh, and I figured
that if I preprocess them with sed, I could covert them into
Lisp form.  It seemed like a cool enough hack to post.

Here is what you do:

(,sed -e "s/^/#(/"               ;convert to lisp vector     
             -e "s/[[]/#(/"             ;dates are vectors too! 
             -e
"sx\\([0-9][0-9]\\)/\\([A-Z][a-z][a-z]\\)/\\([0-9]*\\):\\([0-9]*\\):\\([0-9]*\\):\\([0-9]*\\)x\\6
\\5 \\
\4 \\1 \\2 \\3x"                                               
             -e "y/]/)/"                ;close date             
             -e "s/$/)/"                ;close line 
             )

(excuse what my news poster did to that long line).

Basically, you put a #( at the beginning, a ) at the end,
and re-arrange the embedded date and voila, a readable vector.

Maybe a sed wizard knows a more clever way of doing this, but
I thought it was neat.



<Prev in Thread] Current Thread [Next in Thread>
  • Parsing hack, Janet Bell <=