Now I have learnt to instinctively stop before doing anything destructive and double-check and double-check again! This also applies to SQL `DELETE` and `UPDATE`!
I know that `-r` was not neccessary but hey that was a biiiig mistake of mine!
Now I have learnt to instinctively stop before doing anything destructive and double-check and double-check again! This also applies to SQL `DELETE` and `UPDATE`!
I know that `-r` was not neccessary but hey that was a biiiig mistake of mine!
find /backups/ -mtime '-30' -printf 'rm -f %p\n' > very_scary_deletes.sh
This gives you a static script with a bunch of rm's. You can read that, check it, give it to people to validate and when you eventually run it, it deletes exactly those files.Another way is sometimes: `echo *.txt~` and when you like the result, replace `echo` with `rm`.
One of my "oopsies" involved aggressive <up> and <enter> usage and a previous `rm -rf *` running in /home...
Though for me, I think the greater risk would be from not having a record of what I'd run.
rm ./~ is likely the easiest.
Another option, shell dependent, would be to turn off shell globbing.
The `GNU` version of `find` has a `-maxdepth` option so
find . -iname '~' -maxdepth 1 -exec rm {} \;
would work, but I don't like relying on `GNU` extensions.