Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Convert your min/max dates into "seconds since epoch",</p> <pre><code>MIN=`date --date="$1" +%s` MAX=`date --date="$2" +%s` </code></pre> <p>Convert the first <code>n</code> words in each log line to the same,</p> <pre><code>L_DATE=`echo $LINE | awk '{print $1 $2 ... $n}'` L_DATE=`date --date="$L_DATE" +%s` </code></pre> <p>Compare and throw away lines until you reach <code>MIN</code>,</p> <pre><code>if (( $MIN &gt; $L_DATE )) ; then continue ; fi </code></pre> <p>Compare and print lines until you reach <code>MAX</code>,</p> <pre><code>if (( $L_DATE &lt;= $MAX )) ; then echo $LINE ; fi </code></pre> <p>Exit when you exceed <code>MAX</code>.</p> <pre><code>if (( $L_DATE &gt; $MAX )) ; then exit 0 ; fi </code></pre> <p>The whole script <strong>minmaxlog.sh</strong> looks like this,</p> <pre><code>#!/usr/bin/env bash MIN=`date --date="$1" +%s` MAX=`date --date="$2" +%s` while true ; do read LINE if [ "$LINE" = "" ] ; then break ; fi L_DATE=`echo $LINE | awk '{print $1 " " $2 " " $3 " " $4}'` L_DATE=`date --date="$L_DATE" +%s` if (( $MIN &gt; $L_DATE )) ; then continue ; fi if (( $L_DATE &lt;= $MAX )) ; then echo $LINE ; fi if (( $L_DATE &gt; $MAX )) ; then break ; fi done </code></pre> <p>I ran it on this file <strong>minmaxlog.input</strong>,</p> <pre><code>May 5 12:23:45 2009 first line May 6 12:23:45 2009 second line May 7 12:23:45 2009 third line May 9 12:23:45 2009 fourth line June 1 12:23:45 2009 fifth line June 3 12:23:45 2009 sixth line </code></pre> <p>like this,</p> <pre><code>./minmaxlog.sh "May 6" "May 8" &lt; minmaxlog.input </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload