#!/usr/bin/env zsh emulate -L zsh setopt err_exit for logfile in logs/*.log(N); do lines=$(grep -c "" "$logfile") print -r -- "$logfile:$lines" done