LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Schoolboy error - arrrggghhh!!! (https://www.linuxquestions.org/questions/linux-general-1/schoolboy-error-arrrggghhh-812970/)

devnull10 06-08-2010 05:38 PM

Schoolboy error - arrrggghhh!!!
 
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!! :(

smeezekitty 06-08-2010 05:55 PM

Never tried it but i have heard of test disk.

Tinkster 06-08-2010 06:13 PM

Moved: This thread is more suitable in <Linux - General> and has been moved accordingly to help your thread/question get the exposure it deserves.

Tinkster 06-08-2010 06:19 PM

Quote:

Originally Posted by devnull10 (Post 3997115)

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]*).



Cheers,
Tink

devnull10 06-08-2010 06:29 PM

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.

Tinkster 06-08-2010 08:49 PM

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
Code:

040 SPACE
041 !
042 "
043 #
044 $
045 %
046 &
047 ´
050 (
051 )
052 *
053 +
054 ,

or
Code:

-a
.
.
-h

may be wiped ... now *I* don't have any of those, ymmv.


Cheers,
Tink

arizonagroovejet 06-09-2010 02:26 PM

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!

devnull10 06-09-2010 03:28 PM

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! :)


All times are GMT -5. The time now is 07:37 PM.