Skip to content

Instantly share code, notes, and snippets.

@selfawaresoup
Created August 11, 2022 14:55
Show Gist options
  • Save selfawaresoup/afdb3c47f9c833630bd1456cac30c2fa to your computer and use it in GitHub Desktop.
Save selfawaresoup/afdb3c47f9c833630bd1456cac30c2fa to your computer and use it in GitHub Desktop.
Merge CSV access logs
#!/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