Skip to content

Instantly share code, notes, and snippets.

@milanaleksic
Last active December 16, 2015 08:09
Show Gist options
  • Save milanaleksic/5403790 to your computer and use it in GitHub Desktop.
Save milanaleksic/5403790 to your computer and use it in GitHub Desktop.
Count number of lines in log per day with specific string (good found counting number of server restarts for example)
#!/bin/bash
perl -e 'use POSIX qw(strftime); $i=0; while($i<10) { $dt=strftime "%Y-%m-%d",localtime(time()- 3600*$i*24); print $dt.": "; print `cat server.log | grep "server restarted" | grep -c "$dt"`; $i++; }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment