I had asked a question a while ago about how to pull specific info from a log file, and got some useful answers, but I don't quite have what I need yet. What I have so far:
#!/bin/bash mkdir result cd $1 ls | while read -r file; do egrep "ERROR|FAIL|WARN" > ../errors-$file done cd .. mv errors-* result
Here's what I want in total: the script scans through a directory of logs, grabs each line of text (some are multi-line) that includes ERROR|FAIL|WARN, and outputs them in a directory called "result" with each individual file being named based on their source file.
It works when my target log directory only has one text file in it, but it doesn't work when my target directory has directories and log files at different levels within it. I know it's because the "../errors-$file" bit in the script, but I'm not sure how to change it.
Any help would be great, and I apologize in advance if it's poorly phrased.