#!/bin/bash
file=$2
month=$1
year=date +%Y
echo "Searching $file for days in $month..."
for day in {1..31} do query=$(printf "\\[%02d/%s/%s" $day $month $year) outfile=$(printf "out_%s_%s_%02d.gz" $year $month $day) count=$(zgrep -c "$query" "$file") if [ $count -gt 0 ] then printf "Found %d entries for %s/%02d/%s...\\n" $count $month $day $year zgrep "$query" "$file" | gzip >> "$outfile" fi done
exit 0