#!/bin/sh for file in $(find . -name '*.out' | xargs grep -n error) do mail "$file has an error in it!" -m operator@my.datacenter.org done