Fixed asking confirmation on rm command with –f flag issue. Tested various deletion cases and is working.
You can add the following script in .bashrc file.
rm() {
if [[ $* == -rf* ]]; then
shift 1;
command rm -rfi "$@" | more
elif [[ ${@: -1} == -rf* ]]; then
command rm "$@" -rfi | more
else
command rm -i "$@"
fi
}
Please make sure no alias for rm is set otherwise while executing the source .bashrc we will get error.
This works when we give –rf on first as well as on last like as follows and also it works for files (so no need of alias rm=rm-i)
[root@localhost ~]# mkdir test
[root@localhost ~]# rm -rf test
rm: remove directory ‘test’?
[root@localhost ~]# rm test -rf
rm: remove directory ‘test’?
[root@localhost ~]#