Thursday, 21 June 2012

Bash: example using grep and sed to process a MarkLogic ErrorLog.txt file

Here's an exammple of how grep, sed, sort and uniq can be used to debug entries in a log file (in this case, I'm debugging a problem with a CPF pipeline in MarkLogic). In essence, this process filters all the lines pertaining to a CPF processing action, removes the first part of the line to remove timestamps and unnecessary information (leaving just a document URI), sorts them into an order then returns just the unique document URIs:
grep "Processing some-problem-query.xqy" ErrorLog.txt | sed "s/^.*.xqy: //g" | sort | uniq

No comments: