Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Grep'ping on Unix without perl-compatible gnu grep - can you do it better?

by kielstirling (Scribe)
on Feb 01, 2013 at 02:35 UTC ( #1016426=note: print w/ replies, xml ) Need Help??


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


Comment on Re: Grep'ping on Unix without perl-compatible gnu grep - can you do it better?
Select or Download Code
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016426]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2015-07-05 23:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls