Skip to content

Instantly share code, notes, and snippets.

@amckenna
Created April 14, 2016 17:07
Show Gist options
  • Save amckenna/86495f2fb268eec9c8879fbc1302167e to your computer and use it in GitHub Desktop.
Save amckenna/86495f2fb268eec9c8879fbc1302167e to your computer and use it in GitHub Desktop.
protecting against rm -rf
✔ ~
10:04 $ cd Downloads/
✔ ~/Downloads
10:04 $ mkdir temp
✔ ~/Downloads
10:04 $ cd temp/
✔ ~/Downloads/temp
10:04 $ ls
✘-1 ~/Downloads/temp
10:04 $ touch -- -@
✔ ~/Downloads/temp
10:04 $ ls
total 0
-rw-r--r-- 1 a staff 0B Apr 14 10:04 -@
✔ ~/Downloads/temp
10:04 $ touch {1..4}
✔ ~/Downloads/temp
10:04 $ ls
total 0
-rw-r--r-- 1 a staff 0B Apr 14 10:04 -@
-rw-r--r-- 1 a staff 0B Apr 14 10:04 1
-rw-r--r-- 1 a staff 0B Apr 14 10:04 2
-rw-r--r-- 1 a staff 0B Apr 14 10:04 3
-rw-r--r-- 1 a staff 0B Apr 14 10:04 4
✔ ~/Downloads/temp
10:04 $ rm -rf *
rm: invalid option -- '@'
Try 'rm ./-@' to remove the file ‘-@’.
Try 'rm --help' for more information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment