Created
June 5, 2025 16:26
-
-
Save vertexvaar/41598232517f19ddaa599ff0569167af to your computer and use it in GitHub Desktop.
Process log file into ordered and counted list of entries
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
# Remove the leading 38 characters (`[05-Jun-2025 02:02:18 Europe/Berlin] `) | |
cat /var/log/php/php-fpm-web.log | cut -b 38- > php_1.log | |
# Remove the realpath web root portion which changes with each deployment | |
cat php_1.log | sed 's|/var/www/deployed/releases/[0-9]*||' > php_2.log | |
# sort first, so uniq reduces all eqal subsequent lines to one, add a counter for each reduced line and sort by the counter | |
cat php_2.log | sort | uniq -c | sort -bgr > php_3.log | |
# show the list of errors, ordered by number of times logged | |
less php_3.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment