#!/usr/bin/env fish for file in (find . -name "*.log"); set -l out (echo $file | sed 's/log$/avg/'); echo "processing $file to $out..."; echo -n "AVG," > $out; for col in (seq 2 15); tail -n 50 "$file" | cut -d, -f $col | jq -j -s add/length >> $out; echo -n "," >> $out; end; echo "" >> $out; end