Reputation: 19
Lately ive been busy playing around with bash on my linux operating system, and im also using it too sort files. But this does not seem to work. Is there an alternitive way of what im doing or is it wrong?
echo -n "Are you sure you would like to delete this/these files? [y/n]"
if [ $answer == "y" ]; then
echo -n "Which File would you like to delete?"
rm $answer
else
echo "canceled!"
fi
Upvotes: 0
Views: 44
Reputation: 1428
Check the following usage of "read" command
read -n1 -p "Are you sure you would like to delete this/these files? [y/n]: " answer
if [ "$answer" == "y" ]; then
read -p "Which File would you like to delete: " filename
rm $filename
else
echo "cancelled!"
fi
Upvotes: 1