I would like to take the html piece and pass it to pygmentize to colorize it accordingly. I'm wondering how I could use sed or some other cli tool to get that accomplished.
I tried a bunch of sed one-liners and tried to use the following SO questions:
- Sed multiline replacement question
- Using or in multiline sed replacement
- sed or awk multiline replace
I have the following log:
2012-03-26 18:04:27,385 9372 [main] ERROR web.commons.exception.ServiceInvocationException -
Response from server cannot be decoded to JSON, responsePayload = <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing jetty-url. Reason:
<pre> Not Found</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</body>
</html>
org.codehaus.jackson.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: java.io.StringReader@369133f6; line: 1, column: 2]
UPDATE I'm adding this to a longer command:
mvn -U test | (while read line; do echo ${line} | sed -e "s/.*ERROR.*/`echo -e '\e[91m&\e[0m'`/g" -e "s/.*\(WARN|INFO\).*/`echo -e '\e[93m&\e[0m'`/g"; done)
I used this as part of a longer command:
TXR:
For illustration purposes, we replace
pygmentize
with a command that replaces every letter in the HTML with X.Test run:
Should do it.
To remove the "crap" before the first html tag, get sed to put the html tag on it's own line.