Live data from Hacker News

How to delete all your files

reddit.com

31–40 of 66 posts

Re: How to delete all your files

#31
post #3

I once saw a friend nearly delete all their files using tip#3 from the thread: > never use only * as a wildcard. A ./* would save you in most cases My friend typod that for /* in an rm -rf command but caught it just in time. They seemed like unnecessary characters to me if it does the same as *, and I don't think they do it anymore, but now I'm not sure which is worse... I suppose good backups just go a long way what…

I just did that last weekend! After an allnighter, which isn't easy for me anymore, I typed: ``rm -rf. /*`` with the dot and the space reversed. When the shell threw an error in my face, I thought, "oh, an extra dot." so I deleted the dot and re-run the command. And there goes my configs and most of the dotfiles in my home dir. Luckily, I have backup for some of those, so it wasn't a complete disaster. I don't trust…

It doesn't hurt to do some variation of pointing and calling when doing destructive commands like rm https://en.wikipedia.org/wiki/Pointing_and_calling

Re: How to delete all your files

#32
post #22

There's a lot of operations from the command line that are too easy to screw up. As much as I love having the power available and I'd certainly not give it up, I can't deny that GUIs (or even just TUIs) are much safer since you can visually validate the selection you've made and there's nothing to make a typo on. They also tend to ask for confirmation on destructive actions or provide an undo mechanism. Maybe we need…

Just get a snapshotting filesystem.

Re: How to delete all your files

#34
post #22

There's a lot of operations from the command line that are too easy to screw up. As much as I love having the power available and I'd certainly not give it up, I can't deny that GUIs (or even just TUIs) are much safer since you can visually validate the selection you've made and there's nothing to make a typo on. They also tend to ask for confirmation on destructive actions or provide an undo mechanism. Maybe we need…

If you're using postgres (and maybe others?) it can be handy to use the "returning" keyword -- e.g. "update foo set x = y where z returning *" -- to get an immediate look at the updated rows. Maybe not so good though if touching more than a few dozen rows intentionally.

Re: How to delete all your files

#35

rsync -r ./ ~/Documents/ Why would I even need to use *, if I wanted all files from a directory?

Because rsync semantics around the trailing slash are a little confusing and unusual, it's pretty common IME for people to intentionally explicitly define paths to the file with rsync, in order to avoid having to look up which way they need to write the target path.

Use a dot after the trailing slash and there is less confusion. "Blabla/." means "(everything) in the Blabla directory". Fairly self-explanatory/un-confusing and no need for "*"

Re: How to delete all your files

#36
post #12

You almost never need to use "*". Use ".", or go up a dir and type the name of the dir.

Yes thanks. I thought running rsync with a "*" looked odd, but didn't completely understand why until now.

Funnily enough, rsync is one of the commands for which you might be more tempted to use * instead of going up a directory, because the relative path names go over the wire.

Re: How to delete all your files

#37

Another example of why shell languages are insane interfaces. Only someone who works on writing shell scripts all day could keep in their head all the things like this that could go wrong and how to defend against them.

Sadly this is one of the sanest answers. ./* or always using -- are coping mechanisms. We've internalized the UNIX warts so hard that we no longer perceive them.

I've moved to writing scripts in python instead. It's horribly verbose, but at least it's predictable and doesn't require the use of noisy disclaimers on every call to defend against rare cases.

There's definitely a need for a terser sane scripting language, but I haven't found one yet.

Re: How to delete all your files

#38
Shell globbing + filenames which happen to be switches is one of the first things mentioned in the Unix Hater's Handbook IIRC

I guess every generation of Unix users will have to independently rediscover this the hard way in perpetuity.

Re: How to delete all your files

#39
post #21

I mixed up dd's "of" and "if" args once when trying to image a disk. And of course, it failed somewhere in the middle after borking something important.

> At one point, Linus had implemented device files in /dev, and wanted to dial up the university computer and debug his terminal emulation code again. So he starts his terminal emulator program and tells it to use /dev/hda. That should have been /dev/ttyS1. Oops. Now his master boot record started with "ATDT" and the university modem pool phone number. I think he implemented permission checking the following day. Fro…

You'd think, but a lot of people blindly follow tutorials that Google gives them.

As an example, here's my #2 result for, "Linux command line create bootable usb drive from iso":

https://www.tecmint.com/create-an-iso-from-a-bootable-usb-in...

It instructs you to run this command, despite explaining what "if" and "of" mean in the following paragraph:

>sudo dd if=/dev/sdb1 of=/home/tecmint/Documents/Linux_Mint_19_XFCE.iso

Proofreading is harder and less profitable than SEO.

Re: How to delete all your files

#40

Earlier quoted context omitted.

> At one point, Linus had implemented device files in /dev, and wanted to dial up the university computer and debug his terminal emulation code again. So he starts his terminal emulator program and tells it to use /dev/hda. That should have been /dev/ttyS1. Oops. Now his master boot record started with "ATDT" and the university modem pool phone number. I think he implemented permission checking the following day. Fro…

You'd think, but a lot of people blindly follow tutorials that Google gives them. As an example, here's my #2 result for, "Linux command line create bootable usb drive from iso": https://www.tecmint.com/create-an-iso-from-a-bootable-usb-in... It instructs you to run this command, despite explaining what "if" and "of" mean in the following paragraph: >sudo dd if=/dev/sdb1 of=/home/tecmint/Documents/Linux_Mint_19_XFCE.…

In my case, it was simpler. Just mixing up, mentally, which disk device was the source, which was the dest.
Post reply on HN