#!/bin/sh

newline='
'

for f in h cpp cxx txx
do
  filenames=`find . -type f -name "*.${f}"`
  number_of_files=`find . -type f -name "*.${f}" | wc -l`
  for g in ${filenames}
  do
    lastline=$(tail -n 1 ${g}; echo x); lastline=${lastline%x}
    lastcharacter="${lastline#"${lastline%?}"}"
    echo "${lastcharacter}" > /tmp/a.txt
    echo "${newline}" > /tmp/b.txt 
    match=`diff /tmp/a.txt /tmp/b.txt | wc -l`  
    [ "${match}" != "0" ] && echo >> ${g}   
  done
done
rm /tmp/a.txt /tmp/b.txt
