Skip to content

Instantly share code, notes, and snippets.

@dmgig
Created March 22, 2016 20:21
Show Gist options
  • Select an option

  • Save dmgig/61a5032d29b71f3c369c to your computer and use it in GitHub Desktop.

Select an option

Save dmgig/61a5032d29b71f3c369c to your computer and use it in GitHub Desktop.
Show First Line of Compressed Logs
#!/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