Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable confirmation alert when using 'rm' command to delete files / folders? [closed]

I have found that we cannot recover files/folders when deleted using rm command from here

But, is it possible to add a confirmation alert when using rm command in the terminal?

like image 613
webster Avatar asked May 13 '15 07:05

webster


People also ask

How do you make rm ask you to confirm before it deletes a file?

Now, when you delete a file using the “rm” command, a confirmation displays to make sure you want to delete the file. Press “y” to delete the file, or “n” to keep it. When you enter “rm –r” to delete a folder, you will also get the confirmation.

Does rm command ask confirmation?

The good news is that, rm has an -i flag which prompts (to confirm) you before removing every file. As you can see, you're prompted to confirm the remove operation of the file hello. txt. To confirm, press y and then press <Enter>.

Which is the command used to remove or delete your file without a confirmation message?

Syntax: rm command to remove a file When rm command used just with the file names, rm deletes all given files without confirmation by the user.

What command is used to delete a file with confirmation give an example?

If you use the del /p command, you'll see the following message: FileName, Delete (Y/N)? To confirm the deletion, press Y.


1 Answers

You can use the -i flag:

rm -i someFile.txt 

If you're concerned you may forget to do this, you could alias the rm command:

alias rm="rm -i" 

If you place this alias in one of the files sourced when you start a session (e.g., .bashrc), you'll have it available in all your future terminal sessions.

like image 164
Mureinik Avatar answered Sep 28 '22 01:09

Mureinik