i want to move files and directory to a folder called deleted on my home directory. I want to mimic rm -r command.. i made this code and it only moves all the files from the directory but don't mv the directory. please help i tried everything that can to my mind.
#!bin/bash
function removeDir () {
if ! [ "$(ls -A "$1" )" ]
then
mv -f $1 ~/deleted
else
cd $1
local files=$(ls -A)
echo $files
for f in $files
do
f2=$(readlink -f $f)
if [ -d $f2 ]; then
removeDir $f2
else
mv -f $f2 ~/deleted
fi
done
fi
}
removeDir $@