Using perl to grep

If you are not a fan of grep's regular expressions you can use perl in the same way, by creating the following perl script:

#!/usr/bin/env perl -w
#like grep but using a perl compatible regex
while(<STDIN>){   #read in file
  if(m/$ARGV[0]/){print;}    #print any matching lines
}
exit(0);

You can run this script like so:

cat file.txt | script.pl ^helloworld

Last updated: 10/05/2006