Why isn't my perl one liner working? -
I'm trying to get the number of errors from an HTML log file. Here is my code (yes, I know that I'm mixing bash and pearl):
for line in path path- txt`; Grep failed $ {line} | Perl -pe 'm / \ d + /'; I just hope to get a list of numbers, for example,
0 0 0 0 6 < / Pre Total failure: & lt; Strong> 0 & lt; / Strong> But instead I am getting the full line which has an error, e.g. Total failure: & lt; Strong & gt; 1 & lt; / Strong> Total failure: & lt; Strong & gt; 0 & lt; / Strong> Total failure: & lt; Strong & gt; 0 & lt; / Strong> Total failure: & lt; Strong & gt; 0 & lt; / Strong> Total failure: & lt; Strong & gt; 1 & lt; / Strong> Total failure: & lt; Strong & gt; 6 & lt; / Strong> What am I seeing?
perl -pe 'm / \ d + /'; Just display a pattern match, the printed line will not be changed. If you only want to print the number, then you need something: perl -pe 's / \ D + // g' # change $ _ or
perl -nE 'says $ 1 if / (\ d +) /' # print match only but Why not use all the Pearl?
perl -nwE '$ 1 if say /Failed.*(\d+)/'passs.txt
Comments
Post a Comment