3 ms·
And always, always, always! test commands (or queries, for that matter) before executing them. For instance, my example would run 'sed' multiple times on files
by Confusion 16y ago
And always, always, always! test commands (or queries, for that matter) before executing them. For instance, my example would run 'sed' multiple times on files containing multiple matches of the string grep searches for. And it should have been cut -d':' -f1. Running it without the 'sed' command would have made both those things clear immediately. If you think you know for sure it does what you intend it to do, but you didn't test it, then it doesn't do what you think it does.
- jacquesm 16y agoA good trick for that is to type in the whole command with 'echo' as the final one in the place of the command that actually makes changes. Then you replace the echo with the 'real' thing on the next run if the results where what you expected them to be. In the case of 'rm -rf $1. *' that would save you a lot of hunting around for backups ;)
- bd 16y agoThis also works for SQL commands: use SELECT before UPDATE/DELETE with the same WHERE clause for sanity check.
- trafficlight 16y agoThis one is super important. I just got burned by this a couple of days ago. Sometimes I blow by the WHERE clause because I have a happy Enter finger. It's also not a bad idea to do a quick mysqldump of the database you are working on, just in case.
- Confusion 16y agoYeah, I made it a habit to start entering a query by typing 'WHERE', before anything else.
- jacquesm 16y agoI always thought the missing where defaulting to all records was a bug in the spec, and would have much preferred it if 'where true' was a mandatory thing on deletes and mass updates instead of the current default.