3 ms·
> And I always write the WHERE clause before the DELETE or UPDATE keywords. I sometimes get nervous typing 'rm -r' commands, since it starts with a very broad
by chriswarbo 5y ago
> And I always write the WHERE clause before the DELETE or UPDATE keywords.
I sometimes get nervous typing 'rm -r' commands, since it starts with a very broad path, and only narrows-down as we type more, e.g. if we hit enter prematurely when typing 'rm -r ~/Downloads/archive.zip' we might delete our entire home directory, or all of our downloads.
For this reason I often prefix dangerous steps with 'echo'; once I'm confident it's correct, I'll then run the script and double-check that variables/flags/etc. expanded as expected; and only then will I remove the echoes.
- twic 5y agoSimilarly, i sometimes start writing the command line with 'ls' or 'find', and then run it, and once i'm satisfied it describes the right things, i change the find to an rm.
- tux3 5y agoI always write rm <path> -rf for this reason (I was surprised to learn that on some systems, the flags are in a fixed position, at the start!)
- ndsipa_pomu 5y agoOne reason for having the flags before the <path> is so that you can terminate the flags by using '--'. This is especially useful to prevent dubious files being expanded that might start with '-' and be interpreted as flags that leads to unexpected results.
- tux3 5y agoNote that my Debian's `rm` happily supports terminating flags using `--` when necessary, so wanting to support `--` syntax doesn't have to come at the expense of writing -r last. Almost always, if I'm inputting `rm` manually in a shell, I don't need `--`; very few filenames on my disk start with -.
- leghifla 5y agoWhen I was still a student, I accidentally erased all my project source code with: rm * .o I was puzzled by the message ".o: No such file", and then understood why... Now, I always start with ls and if satisfied of the output, replace ls with rm