I am working on mimicing rm behaviour with added functionality similar to recycle bin. This is what my code looks like so far:
#!/bin/bash
# tests if bin does not exist and if true, create it
binName=$HOME/deleted
if [ ! -d $binName ]
then
mkdir $binName
else
echo "recycle bin exists"
fi
if [ $# -eq 0 ] ; then
echo "No argument passed"
elif [ -d $1 ] ; then
echo "is dir"
elif [ ! -e $1 ] ; then
echo "does not exist"
else
mv $1 $binName
fi
I am struggling with is adding an under score and inode number to the end of the moved file to avoid duplicate file errors in the bin directory. I tried using brace expansion from this link but it causes errors.