Hi I'm new here and just needed a small helping hand
The problem is that I am trying to restore a file to a location that it had previously - unfortunately I know what the error is but don't know how to solve it.
for example the file test1 has a directory of /home/dave/test1 it is then moved to a dustbin type feature (directory). When retrieving the file and trying to put it back I cannot as the previous location is /home/dave/test1. Any way to sort of grep/find the test1 out - has to be generic for all files trying to do the same.
Code:
if [ "$1" == "" ]; then
echo "You must enter the file's name you are wanting to restore"
elif [ ! -e "/home/dave/dustbin/$1" ]; then
echo "No file in dustbin named '$1' please check spelling"
else
grou=$(basename "$1")
location=`grep $1 /home/dave/fileorigin`
filename=`basename "$location"`
mv $filename $location
#echo $filename
#echo $location
fi