#!/bin/sh

echo "Processing folders: $FOAM_SRC $FOAM_APP"
echo ""

find $FOAM_SRC $FOAM_APP -name options -type f | while read item
do
    if [ $(grep -v '^$' $item | wc -l) -ne $(grep -v '^$' $item | sort -u | wc -l) ]
    then
        grep -v '^$' $item | sort > ${item}.sorted
        grep -v '^$' $item | sort -u > ${item}.unique

        echo "File with duplicate lines: $item - duplicate lines:"
        diff --horizon-lines=0 ${item}.sorted ${item}.unique | grep "<"

        rm ${item}.sorted ${item}.unique

        echo ""
    fi
done

echo "Processing complete."
