4 ms·
> Not really, a lot of novice unix users are of the habit of removing files with -rf switch. I cringe everytime I see it. Every few days I remind myself of thi
by daurnimator 12y ago
> Not really, a lot of novice unix users are of the habit of removing files with -rf switch. I cringe everytime I see it.
Every few days I remind myself of this.... then I have to delete another directory with a git repository in it, and end up add the -f in again
- couchand 12y agoI run into this all the time, too. Now my -rf usage is almost always wrapped by this: rmgit() { git status read -p "Are you sure? " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]] then rm .git -rf fi }
- anon4 12y agoI think this would be a bit better for interactive cases. Note: written just now, I haven't actually felt the need for this safeguard... yet. rmrf() { (echo "The following files are going to be deleted!!!" for FILE in "$@"; do echo "<<<" "$FILE" ">>>" done) | less read -p "Are you sure? " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]] then rm -rf "$@" fi }
- colanderman 12y agoDoesn't help against network filesystems mounted in subdirectories. --one-file-system (which really ought to be the default) prevents this.