Created
March 22, 2016 20:21
-
-
Save dmgig/61a5032d29b71f3c369c to your computer and use it in GitHub Desktop.
Show First Line of Compressed Logs
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
| #!/bin/bash | |
| LOGPATH='/var/log/apache2' | |
| FILES="$(ls -1 ${LOGPATH}/access_log* )" | |
| for FILE in $FILES | |
| do | |
| echo $FILE | |
| if [ ${FILE: -3} == ".gz" ] | |
| then | |
| echo " "` gzip -cd ${FILE} | head -1` | |
| else | |
| echo " "`head -1 ${FILE}` | |
| fi | |
| done | |
| echo "--finished--" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment