perl one liner alternative to this bash "chain"?

Posted by Michael Mao on Stack Overflow See other posts from Stack Overflow or by Michael Mao
Published on 2010-04-12T06:36:45Z Indexed on 2010/04/12 6:43 UTC
Read the original article Hit count: 542

Filed under:
|

Hello everyone:

I am trying to comprehend Perl following the way describe in the book "Minimal Perl".

I've uploaded all source txt files onto my own server : results folder

I got the output from using several bash commands in a "chain" like this:

 cat run*.txt | grep '^Bank[[:space:]]Balance'| cut -d ':' -f2 | grep -E '\$[0-9]+'

I know this is far from the most concise and efficient, but at least it works...

As our uni subject now moves onto the Perl part, I'd like to know if there is a way to get the same results in one line?

I am trying something like the following code but stuck in the middle:

Chenxi Mao@chenxi-a6b123bb /cygdrive/c/eMarket/output
$ perl -wlne 'print; if $n=~/^Bank Balance/'
syntax error at -e line 1, near "if $n"
Execution of -e aborted due to compilation errors.

© Stack Overflow or respective owner

Related posts about perl

Related posts about homework