Created
August 11, 2022 14:55
-
-
Save selfawaresoup/afdb3c47f9c833630bd1456cac30c2fa to your computer and use it in GitHub Desktop.
Merge CSV access logs
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
#!/usr/bin/env bash | |
# merges CSV webserver access logs (like the ones FastMail provides for their static website hosting) | |
# into a new file, removing duplicate entries and sorting by date descending | |
LOGS=$(find . -name "access-log-*.csv" -type f) | |
echo "" > .temp | |
for L in $LOGS | |
do | |
echo $L | |
cat $L >> .temp | |
done | |
cat .temp | sort -k1 -t, -u -r > merged.csv | |
rm .temp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment