Hello I need parse a log. I have a problem when log has more than one line (in case of error) For example: If no errors
Last error code [0], message [No errors encountered.]
If conversion error
Last error code [8425], message [ERROR: Writer execution failed.
Database error: [0] [
FnName: Execute -- [DataDirect][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]Conversion failed when converting the varchar value 'amica' to data type int., SQLSTATE [22005]
FnName: Execute -- [DataDirect][ODBC lib] Function sequence error, SQLSTATE [S1010]]]
I need to get log between [ ]
Base on first example it should be:
No errors encountered.
base on second example it should be:
ERROR: Writer execution failed. Database error: [0] [FnName: Execute -- [DataDirect][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]Conversion failed when converting the varchar value 'amica' to data type int., SQLSTATE [22005]FnName: Execute -- [DataDirect][ODBC lib] Function sequence error, SQLSTATE [S1010]]
I'm writing my script in awk. Is it possible to do this using regular expressions? I'm not familiar with regular expressions, but I tried something like this
(?<=, message \[).+\n
but it doesn't work with log which has many lines, and I don't know how to cut last one char "]"