#!/bin/sh PGINCLUDEDIR=$1 [ -z "$PGINCLUDEDIR" ] && PGINCLUDEDIR=/usr/include/postgresql find $PGINCLUDEDIR -name '*.h' | sed "s|$PGINCLUDEDIR/||" >/tmp/$$ lastlc=-1 lc=0 while [ $lc -ne $lastlc ] do lastlc=$lc ( ( cd ~/mypackages/pg7.1/postgresql-7.1beta4/src/include cat /tmp/$$ | xargs grep '#include' 2>/dev/null cd /usr/include/postgresql cat /tmp/$$ | xargs grep '#include' 2>/dev/null ) | grep -v '<' | sed 's/^.*"\(.*\)".*$/\1/' cat /tmp/$$ ) | sort -u >/tmp/$$-1 mv /tmp/$$-1 /tmp/$$ lc=`wc -l /tmp/$$ | awk '{print $1}'` done ( cat /tmp/$$ find $PGINCLUDEDIR -name '*.h' | sed "s|$PGINCLUDEDIR/||" ) | sort | uniq -u rm /tmp/$$