Sunday, May 5, 2024
Homepage · rm
 Popular · Latest · Hot · Upcoming
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 656  / 2 Years ago, fri, february 25, 2022, 5:16:46

I just created alias rm="rm -I" to prevent from accidental rm command.



-I     prompt  once before removing more than three files, or when removing recursively.
Less intrusive than -i, while still giving protection against most mistakes


But it doesn't work. I don't get any prompt when I use rm -rf


More From » rm

 Answers
2

If you read the help again you'll see it says previous --interactive. This means you can add an -I after all the other arguments (like at the end of the line) and it'll be honoured again!



To do that, you need a function instead of an alias, but just stick this somewhere in your .bashrc (et al) and you're golden:



function rm { /bin/rm "$@" -I; }





A perhaps safer method than even this is using trash-cli's trash-put command. It will put things in your account's trash directory that can be reviewed/restored/emptied normally. It also has dummy -r, -f and, -i arguments so it makes a perfect alias possible:



alias rm="trash-put"

[#28156] Saturday, February 26, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mance

Total Points: 198
Total Questions: 105
Total Answers: 128

Location: South Georgia
Member since Mon, Aug 16, 2021
3 Years ago
;