 <p><code>grep</code> does not recognize <code>\d</code>. Try:</p> <pre><code>$ grep -E 'Info:.*took\s*[0-9.]*\s*[mhd]' logfile Info: Executed check 'bla', result 'pass', took 2.5 minutes. Info: Executed check 'foo', result 'pass', took 3.4 hours. Info: Executed check 'bar', result 'pass', took 2.7 days. </code></pre> <p>Or, better yet:</p> <pre><code>$ grep -E 'Info:.*took\s*[[:digit:].]*\s*[mhd]' logfile Info: Executed check 'bla', result 'pass', took 2.5 minutes. Info: Executed check 'foo', result 'pass', took 3.4 hours. Info: Executed check 'bar', result 'pass', took 2.7 days. </code></pre> <p>Notes:</p> <ol> <li><p><code>egrep</code> is deprecated. Use <code>grep -E</code> instead.</p></li> <li><p><code>grep</code> is supposed to support POSIX regular expressions. <code>\s</code> is a GNU extension and may not be portable. <code>\d</code> is not supported.</p></li> <li><p><code>[:digit:]</code> is unicode-safe which makes it a better choice than <code>0-9</code>.</p></li> <li><p>To match floating point numbers, one must allow a decimal point in addition to digits. Note that, outside of <code>[...]</code>, the period <code>.</code> is a wildcard. Inside <code>[...]</code>, by contrast, it only matches a period.</p></li> </ol> <h3>More portable version</h3> <p>For greps that do not support <code>\s</code>, try:</p> <pre><code>$ grep -E 'Info:.*took[[:space:]]*[[:digit:].]*[[:space:]]*[mhd]' logfile Info: Executed check 'bla', result 'pass', took 2.5 minutes. Info: Executed check 'foo', result 'pass', took 3.4 hours. Info: Executed check 'bar', result 'pass', took 2.7 days. </code></pre>