So I am working on a program that delete files and folders recursively. For some reason I am stucked in endless loop. Please point out where I am wrong.
for file in $1
do
if [ -f $file ] #If it is a file just delete it
then
echo "delete $file"
elif [ -d $file ] #if it is a folder
then
#look inside and see if it is empty or not
if [ "$(ls -A $file)" ]
then
recursive $file #recursively call
else
#if the folder is empty just delete it
echo "delete $file"
fi
fi
done