#
#Write a shell script to add the statement #include <stdio.h> at the beginning of every C source file in 
#current directory containing printf and fprintf. 
#

clear

echo -n "Enter directory name :"
read directory

if [ ! -d $directory ] 
then
    echo "Directory does not exist"
else
	for i in $(find $directory -name "*.[cC]")
	do
		count="$(cat $i | grep -icw 'printf\|fprintf')"
		if [ $count -gt 0 ]
		then
			echo "$(sed '1i\#include<stdio.h>\' $i)" > $i
		fi
		echo $i
	done
fi