Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
So I downloaded some files to my home directory which were named similarly with the exception of the last part, eg screenshot1001.jog, screenshot1002.jpg and so on.. I had about 20 of these and wanted to delete them all, so I did "rm screenshot*".
However - that's not what I did!!! I stupidly, and for some reason unknown to man did "rm screenshot *"!!!!!!
Lost a crap load of files from my home directory as a result!!!
Anyone know how I might get these back (using ext4 filesystem)? I've tried extundelete but had no luck.
Yes, I know I should probably alias rm to rm -i but I'm not a linux n00b and have been using it for years without any problem. I think only having four hours sleep last night didn't help either as I am not concentrating!!
Yes, I know I should probably alias rm to rm -i but I'm not a linux n00b and have been using it for years without any problem. I think only having four hours sleep last night didn't help either as I am not concentrating!!
What I like to do in ~ , ~/documents and ~/downloads (e.g.,) is
to "touch ./-i" ... works in most situations (unless you have
other files in the dir by names of -[a-h]*).
Hi,
Yes, I suppose that would have the same effect as alias'ing but only happens in chosen directories. I just find it too intrusive sometimes that's all but then again I guess I am never going to want to run "rm *" in my home dir! If I did want to remove using wildcards then it wouldn't be matched.
Can I be sure that the -i file will always be hit first (ie, other files won't be deleted first)?
I've also set up a cron job to backup /home weekly (will change to daily when I eventually get around to having an external file server) to a separate partition. I know it would be better doing a remote backup but unfortunately I don't have the facilities to do this.
As i said with the "caveat" ... the * will (by default) glob files in ASCII
order. So if you have (other) files that start with unusual character they
may get killed. So file names starting with
On the bright side, you now understand the value of a back up and anyone else reading this who doesn't have a back up of things they care about will hopefully now understand why they should.
FWIW I've been using *nix command lines for about fifteen years and not only do I always make sure I have rm aliased to 'rm -i' but I also do it for cp and mv. Without -i, cp and mv will silently overwrite an existing file with the target name if it exists.
Everyone makes a typo once in a while. I've lost files as the result of typos and that's why I now alias rm, cp and mv. If you want to delete a bunch of stuff without being asked you can always use -f. If you use -f read what you typed at least twice before hitting enter!
Yep, definitely a valuable lesson. Like I say, I have been using linux for quite a few years now and use unix at work and have always been fine and usually check any such commands. It was just a costly mistake made I think because I wasn't concentrating properly!
Tinkster - I very rarely (in fact probably never) have filenames which start with anything other than an ascii character so i should be ok!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.