I'm new to egrep. What pattern could I use to find all lines that match this pattern: <beginning of line><any amount of whitespace>sub<space>. I want it to return the entire line.
(I'm trying to generate a list of all Perl sub definitions in a list of Perl modules.)
I have a collection of Perl code files which define several subs. Most appear to have some whitespace (spaces or tabs) before the first line of the sub definition:
sub subname {
I want to use egrep (or grep -E) to find all these, because simple grep for the word sub returns lots of lines I don't want to see (like Perl comments and things in quotes).
Examples of lines I don't want to see:
# sub subname {
print "This sub does something"
As far as Amit's post goes, his commands could have been condensed to the following, and would not have worked regardless because I wasn't searching for the exact string "subname." (I thought that would have been obvious.)