#!/usr/bin/perl die "usage: pipegrep pattern command files\n" unless @ARGV; $debugging = 0; $ARGV[0] eq '-i' && do { shift; $insensitiv = 1 }; if ($ARGV[0] eq '-l') { shift; $action = <<'EOF'; print $file,"\n"; next file; EOF } else { $action = <<'EOF'; print $file,"\t:",$_; EOF } # get the pattern an protect the delimiter we'll use. $pat = shift; $pat =~ s/!/\\!/g; # get command and make shure it has a {}. $cmd = shift; $cmd .= ' {}' unless $cmd =~ /{}/; # modify each filename into the corresponding command. for (@ARGV) { $file = $_; $_ = $cmd; s/{}/$file/; s/$/ |/; } # generate the program. $prog = <) { EOF if($insensitiv) { $prog .= <