#!/bin/bash target="${1-.}" find "$target" -name '*.g' | while read g; do f="${g%.g}" [ "$f" -nt "$g" ] || echo "$f" echo "$g" done | xargs rm -f