I’m trying to grab the number of errors from a HTML log file. Here’s my code (yes, I know I’m mixing bash and perl):
for line in `cat paths.txt`; do grep Failed ${line} | perl -pe 'm/\d+/'; done
I’m expecting to simply get a list of numbers, e.g.,
0
1
0
0
0
1
6
But instead I’m getting the entire line that contains the error, e.g.,
Total Failed: <strong>0</strong> Total Failed: <strong>1</strong> Total Failed: <strong>0</strong> Total Failed: <strong>0</strong> Total Failed: <strong>0</strong> Total Failed: <strong>1</strong> Total Failed: <strong>6</strong>
What am I over looking?
perl -pe 'm/\d+/';Will simply perform a pattern match, the line printed will not be changed. If you want to only print the number, you need something like:or
But why not use all perl?