in reply to (How) can I use regex patterns to find matching lines in a textfile?


Here is one way:     perl -ne 'print if /pattern/ and $i++ < 100' file

And here is another:     grep pattern file | head -100

--
John.

Replies are listed 'Best First'.
Re: Re: (How) can I use regex patterns to find matching lines in a textfile?
by Ritter (Sexton) on Nov 20, 2002 at 12:28 UTC
    I am using WinXP... with perl -ne 'print if /pattern/ and $i++ < 100 ' myfile.txt I just get a message "The file can't be found" :( Ritter

      Windows requires double quotes. This should work:     perl -ne "print if /pattern/ and $i++ < 100" file.txt

      --
      John.