$ git grep ' $' | grep -v ^test/ | cut -d : -f 1 | sort -u > /tmp/trailing $ for a in `cat /tmp/trailing` ; do sed -i -e 's/ *$//' $a ; done