This file contains 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
#!/bin/bash | |
echo "Baned last log" | |
awk '($(NF-1) = /Ban/){print $NF}' /var/log/fail2ban.log | sort | uniq -c | sort -n | |
echo "------------ Baned in all files --------------" | |
zgrep -h "Ban " /var/log/fail2ban.log* | awk '{print $NF}' | sort | uniq -c | |
echo "------------ Baned by subnet --------------------" | |
zgrep -h "Ban " /var/log/fail2ban.log* | awk '{print $NF}' | awk -F\. '{print $1"."$2"."}' | sort | uniq -c | sort -n | tail | |
echo "------------ Baned by date -------------------------" | |
zgrep -h "Ban " /var/log/fail2ban.log* | awk '{print $5,$1}' | sort | uniq -c |
This file contains 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
1. Find > Replace | |
2. Click 'Regular Expression' box | |
3. Enter ^\s+ as your search string | |
4. Click 'Find' to confirm it works as anticipated | |
5. Use 'Replace All' to remove all leading spaces from each newline | |
NB. For trailing spaces replace with \s+$ |