#!/usr/bin/perl # Lists commands on the path that contain the given regular expression. # # USAGE: # comgrep.pl my $pat=shift || ""; my %printed; foreach my $p (split ":",$ENV{PATH}) { foreach (glob "$p/*") { next unless -X && -f; s|//|/|g; my ($path, $name)= m|(.*)\/([^/]*)|; print "$_\n" if $name=~m/$pat/o and !$printed{$_}; $printed{$_}=1; } }