in reply to Performing Mathematical Operation on Specific Column of text File

>perl -ane "next unless $F[0]=~/^ZJ/;$count++;$val+=$F[8]}{printf qq|% +d values; mean=%.4f\n|,$count,$val/$count" source.file.name.txt #OUTPUT: 6 values; mean=-1.1958
Use single-quotes for Linux. Format, and redirect output as desired.
see "perl --help" for the meanings of -a, -n, -e, and @F
"}{" is the perl eskimo greeting.

        "You're only given one little spark of madness. You mustn't lose it."         - Robin Williams

  • Comment on Re: Performing Mathematical Operation on Specific Column of text File
  • Download Code