http://www.perlmonks.org?node_id=1016426


in reply to Grep'ping on Unix without perl-compatible gnu grep - can you do it better?

perl -ne 'print if !/^#/ and /foo/' /tmp/foo.txt
is that what you want? Or using the regex for the above post
perl -ne 'print if /^[^#]*foo/' /tmp/foo.txt

Replies are listed 'Best First'.
Re^2: Grep'ping on Unix without perl-compatible gnu grep - can you do it better?
by Tommy (Chaplain) on Feb 01, 2013 at 02:43 UTC

    Very nice...except you still have to account for potential preceeding whitespace before the hashmark /^[[:space:]]{0,}#/

    Tommy
    A mistake can be valuable or costly, depending on how faithfully you pursue correction