Hey I have the following code which checks if the file already exists in the location that it was originally in before it was removed.
This works and if it does not exist then it will be moved which also works,
But My question is how can I get the shell script to ask the user to specify a new name to rename the file to and then store it under the new name if a file with the same name exists already.
The code for the rename should go underneath the echo in the first part of the if
#! /bin/sh
#restore the dustbin contents
if [[ -f "$(grep $1 /root/TAM/store) " ]]; then
echo "A File with the same name already exists please rename this file to store it"
else
mv /root/TAM/dustbin/$1 `grep $1 /root/TAM/store`
cd /root/TAM
rm store
touch store
fi
EDIT
read -p "please enter a new name: " newName
mv /root/TAM/dustbin/$1 /root/TAM/dustbin/$newName
cd /root/TAM
rm store
touch store
To prompt the user, try doing this :