#!/bin/bash for file in `tree -if --noreport | egrep "\.(patch|patch1|diff)$"`; do echo Apply $file patch -p1 < $file if [ $? != 0 ]; then echo "Failed to patch $file" exit 1 fi done echo "Done"