Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2005
    Posts
    6

    Unanswered: Problem with grep

    I need to print the lines in a file that contain searchText1 but NOT searchText2. I am stuck on trying to figure the regular expression for this. I tried using the [^ ... ] operator but it does not seem to work at all.

    Again thank you for any help.

    -Sweetness

  2. #2
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    167
    combine two regular expressions to reach your goal...

    Code:
    open(READ,"<$file") or die $!;
    while(my $line = <READ>){
      print $line if($line =~ /$search1/ && $line !~ /$search2/);
    }
    close READ;
    board.perl-community.de - The German Perl-Community

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •