I'm looking for something pretty similar to this.
The logs look like this:
[09:44:22] [main] ERROR [url/location] - A ONE LINE ERROR
[09:44:22] [main] ERROR [url/location] - Another ERROR
[09:44:22] [main] SOMETHING DIFFERENT
[09:44:22] [main] SOMETHING DIFFERENT AGAIN
[09:44:22] [main] WARN [url/location] - ANOTHER ONE LINE WARN
Line after line with no empty lines between them, though occasionally there are indents when further info is available for a specific piece.
I want to be able to pull every line that includes ERROR (ideally as a script that can pull ERROR And/Or FAIL, WARN, etc.) and display them according to a parameter. It'll make sifting through logs for fails and whatnot much easier.
awkcommand you quoted wouldn't work if all you want is the matching lines. SettingFSis unnecessary, but shouldn't matter. Just printing lines containing a pattern is simple with any of the tools you mention, and perhaps the simplicity of it is what causes confusion. (And the word "chunk" and mentioning indentations).awk '/ERROR/' in.txt,grep ERROR in.txtandsed -n '/ERROR/p' in.txtshould all print the lines containing "ERROR" anywhere on the line, though grep is made just for this.