On Thu, 7 Sep 2000, Vilmos Soti quoth:
~~ Date: Thu, 07 Sep 2000 15:38:50 GMT
~~ Newsgroups: comp.os.linux.misc
~~ Subject: Re: regexp on stdin
~~
~~
~~ > I want to match piped lines from stdin against a
~~ > regular expression. As far as I know I can't use
~~ > expr, because the two arguments must be provided
~~ > as string and you can't use a hyphen as
~~ > substitute for stdin...
~~
~~ It is not clear what you want. Maybe this?
~~
~~ echo Hello world | grep '[Hh]ello'
Use Perl:
echo hello, world | perl -wne 'print if /[Hh]ello/'
I think you will find Perl's regular expressions to be more
powerful than most.
anm
--
BEGIN{ $^W = 0 }; $\ = $/; $$_ = $_ for qw~just another perl hacker~;
my $J = sub { return \$just }; my $A = sub { return \$another };
my $P = sub { return \$perl }; my $H = sub { return \$hacker };
print map ucfirst() . " " => ${&$J()}, ${&$A()}, ${&$P()}, ${&$H()};