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.
|