Created
May 9, 2018 15:08
-
-
Save Artistan/981e4b20e539b092b018fa1ad20e1219 to your computer and use it in GitHub Desktop.
catail.sh :: cat files found in a tails search....
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# thanks to some help | |
# https://unix.stackexchange.com/questions/442672/how-to-continuously-tail-a-log-find-all-files-sed-and-display-cat-the-foun | |
# https://stackoverflow.com/a/26884607/372215 | |
# catail \"/var/log/httpd/modsec_audit.log\" 's/[^\/]*/\./;s/].*$//g' | |
# parameter 1 is the file(s) to log | |
# parameter 2 is the sed regular expression (regex) to search for files within the tailed log | |
# notice the example modsec_audit, this will log file in the audit.log that it wroe if you are logging output in Concurrent mode. | |
catail() ( | |
if [[ -z "$1" || -z "$2" ]]; then | |
echo "catail \"/var/log/httpd/modsec_audit.log\" 's/[^\/]*/\./;s/].*$//g'" | |
return | |
fi | |
tail -f "$1" | while read line; do | |
echo "$line" | sed "$2" | awk '{print $0}' | xargs -n1 cat | |
done | |
) | |
# source catail | |
# catail \"/var/log/httpd/modsec_audit.log\" 's/[^\/]*/\./;s/].*$//g' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment