#!/bin/bash find stm32cubemx -type f |while read file do cat $file | dos2unix | sed -e 's,[\t ]*$,,g' > $file.tmp cnt=$(diff $file.tmp $file | wc -l) if [[ $cnt -gt 0 ]] then echo Fixed $file mv $file.tmp $file else rm $file.tmp fi done