#!/bin/bash ls *png > archivos while read l; do pngcrush -q "$l" "temp.png" mv "temp.png" "$l" done < archivos rm archivos