Skip to content

Instantly share code, notes, and snippets.

@pizzaboxer
Last active March 17, 2023 18:04
Show Gist options
  • Select an option

  • Save pizzaboxer/47286560da389705a715c32895912c79 to your computer and use it in GitHub Desktop.

Select an option

Save pizzaboxer/47286560da389705a715c32895912c79 to your computer and use it in GitHub Desktop.
minecraft server log compiler
#!/bin/bash
# a script i quickly wrote to compile a minecraft server's log history
# place this in the folder of your minecraft server
# after you run it, a 'logs-compiled/' directory should be made
if [[ ! -d "logs-compiled/" ]]
then
mkdir logs-compiled
fi
if [[ -n "$(ls -A logs-compiled/)" ]]
then
rm logs-compiled/*
fi
echo "compiling..."
ls -rt logs/* | while read filename
do
lines=""
if [[ "$filename" == *".gz" ]]
then
lines="$(gzip -dc $filename)"
else
lines="$(cat $filename)"
fi
echo "$lines" | while read line
do
line="[$filename] $line"
echo "$line" >> logs-compiled/all.log
if [[ "$line" == *"Async Chat Thread"* ]] || [[ "$line" == *"[Server]"* ]]
then
echo "$line" >> logs-compiled/chat.log
elif [[ "$line" == *"You are not whitelisted"* ]]
then
echo "$line" >> logs-compiled/whitelist-violations.log
elif [[ "$line" == *"issued server command:"* ]] && [[ "$line" != *"/msg"* ]] && [[ "$line" != *"/tell"* ]] && [[ "$line" != *"/w"* ]]
then
echo "$line" >> logs-compiled/server-commands.log
fi
done
done
echo "done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment