Skip to content

Instantly share code, notes, and snippets.

@linusfoldemo
Created October 8, 2015 07:50
Show Gist options
  • Save linusfoldemo/ba9cde7bb96769fe11b6 to your computer and use it in GitHub Desktop.
Save linusfoldemo/ba9cde7bb96769fe11b6 to your computer and use it in GitHub Desktop.
Simple script to locate logs in a directory structure
#!/bin/bash
die() {
echo $1
echo "Usage: $0 application environment date"
echo "environment is TEST/BETA/DEMO/PROD"
echo "date pattern is yyyy-MM-dd"
exit 1
}
[ $# -ge 2 ] || die "Too few arguments."
APPLICATION=$1
ENVIRONMENT=$2
DATE=$3
if [ $DATE ]; then
find ~/logger/ -iname \*$APPLICATION\*-$ENVIRONMENT\*-$DATE\.log\* | sort
else
find ~/logger/ -iname \*$APPLICATION\*-$ENVIRONMENT\*\.log\* | sort
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment