所以我正在开发一个递归删除文件和文件夹的程序。出于某种原因,我陷入了无限循环。请指出我错在哪里。
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