Created
November 14, 2013 19:21
-
-
Save justnoise/7472716 to your computer and use it in GitHub Desktop.
Sometimes repeatedly grepping through huge logs is time consuming. If you're targeting a specific period in time, just grab that period and dump it to a pruned log file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| filename=access_log.log | |
| output_filename=${filename}_pruned | |
| start_pattern='2013:13:' | |
| end_pattern='2013:16:30:' | |
| start=`grep -n -m1 "$start_pattern" $filename | cut -f1 -d:` | |
| end=`grep -n -m1 "$end_pattern" $filename | cut -f1 -d:` | |
| sed -n "$start,${end}p" $filename > $output_filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment