Skip to content

Instantly share code, notes, and snippets.

@hiroakit
Created July 26, 2015 00:03
Show Gist options
  • Save hiroakit/54ddf4f5dd12fa5d911d to your computer and use it in GitHub Desktop.
Save hiroakit/54ddf4f5dd12fa5d911d to your computer and use it in GitHub Desktop.
IISのログをシンプルにするシェルスクリプト(bash)
if [ $# -ne 1 ]; then
echo "パスをダブルクォートで囲って指定してください。" 1>&2
exit 1
fi
files=$1
for filepath in $files; do
echo $filepath
done
# $1 : Date
# $2 : Time
# $5 : Server IP (reciever)
# $6 : HTTP method
# $7 : URL (without parameter)
# $11 : Client IP (sender)
# $17 : HTTP status
for filepath in $files; do
cat $filepath | awk '$1 !~ "#"{print}' | awk '{ print $1, $2, $5, $17, $6, $11, $7}' >> ./tmp-parsed-log.txt
done
cat ./tmp-parsed-log.txt | awk '$4 == "500"{print}' > 500-error-log.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment