barlop
barlop

Reputation: 13820

perl one-liner like grep?

i'd like perl to do a one-liner like grep

a bit like this, but i'm not sure what to add to make it work

$ (echo a ; echo b ; echo c) | perl -e 'a'

ADDED My answer here covers that and more
https://superuser.com/questions/416419/perl-for-matching-with-regex-in-terminal

Upvotes: 21

Views: 19626

Answers (3)

Joel Berger
Joel Berger

Reputation: 20280

To echo mob's comment:

If you want to use Perl regexes try ack: http://betterthangrep.com/

Upvotes: 5

kurumi
kurumi

Reputation: 25609

You can do the same with Ruby, if you can afford other options

$ (echo a; echo b; echo c) | ruby -ne 'print if /a/'
a
$ (echo a; echo b; echo c) | ruby -ne 'print if $_["a"]'
a

Upvotes: 2

Eugene Yarmash
Eugene Yarmash

Reputation: 150168

(echo a; echo b; echo c) | perl -ne 'print if /a/'

Upvotes: 36

Related Questions