|
|
#1 |
|
Prospect
Join Date: Nov 2003
Posts: 19
|
restoring files deleted with 'rm'
hi everyone,
so i just accidentially deleted some files using 'rm' in the terminal. is there a way to restore these files? i'm running 10.3, panther. thanks, josh |
|
|
|
|
|
#2 |
|
Major Leaguer
Join Date: Nov 2002
Location: Montréal, QC, Canada
Posts: 329
|
in short, no.
perhaps there is some sort of unix/HFS+ util that is able... i am not aware of any. perhaps it's best if from now on you used "rm -i" to get confirmation on deletion.
__________________
sometimes i wish i could pipe my customers to /dev/null |
|
|
|
|
|
#3 | |||||||||||||||||||
|
Prospect
Join Date: Nov 2003
Posts: 19
|
I actually do us 'rm -i' (alias that way), but unfortunately I am too quick to type 'y'. I was writing some Java code and I wanted to clean up my directory so I was going to delete the .class files. So I quickly typed: rm *.java, and pressed y, enter, y, enter, y, enter... a few times until I realized what I was doing. I managed to delete several of my source code files, a couple of which were very small and very easy to rewrite, but at least one of which was very long and fairly complicated. I still haven't been able to find a suitable undelete method, but I did find a java decompiler that works, JAD. Since I still had the .class files I could decompile the source code out of them, and other than my variable names and commenting being stripped from my code, its at least functionally equivalent. But anyway, it seems with HFS+ being a Journaling filesystem there should be some fairly easy tools for undeleting things right after you delete them? Oh well. If anyone comes across any, please post, as something like that could always be useful in the future when I "rm -rf /" by accident. ;-) Thanks, Josh |
|||||||||||||||||||
|
|
|
|
|
#4 |
|
Triple-A Player
Join Date: Jul 2003
Location: Mierlo, Holland
Posts: 120
|
The best means to avoid loosing things:
backup, backup, backup! If you need to undelete (by means of recovering disk blocks that have been added to the list of free blocks): be quick (that is: don't wait too long)! Do as least as possible on the filesystem, since all write actions may involve the old data. This includes installing recovery software (better install it on a separate partition, or run it from a CD). My € 0,02 (two euro-cents) Leo |
|
|
|
|
|
#5 |
|
Major Leaguer
Join Date: Jul 2002
Location: Germany
Posts: 441
|
There's a package called TCT , which contains the unrm and lazarus tools.I didn't use them, so I can't tell if they work on OS X. A short how-to is found here . Note that it is essential that you stop writing onto the disk immediately...
Still better would be to get into the habit of using something like Code:
alias del 'mv \!* ~/.Trash' Code:
alias del '/Developer/Tools/MvMac \!* ~/.Trash'
__________________
"And what have we got in here ? - Ahh, things.." (Louis (2), inspecting kitchen cupboards.) |
|
|
|
|
|
#6 | |||||||||||||||||||
|
Moderator
Join Date: Jan 2002
Location: Montreal
Posts: 29,452
|
No - journaling doesn't do what you think it does. Journalling merely ensures that disk writes are atomic - so that if e.g. the power is interrupted in the middle of a write, the system is able to recover and undo the partial write. It does not provide any permanent records that could be used in un-deleting. |
|||||||||||||||||||
|
|
|
|
|
#7 | |||||||||||||||||||
|
Triple-A Player
Join Date: Jul 2003
Location: Mierlo, Holland
Posts: 120
|
unrm and lazarus
Hi pink! In fact you're moving the 'to be deleted files and dirs' to the thrashcan yourself (via the shell). Does the Finder have any knowledge about where the deleted file etc. are coming from? I guess it does, since it undeletes the file to its previous location. This seems to favor the MvMac tool, which is resource-aware (as opposed to mv). Volunteer wanted to undelete a file removed by either of these (I'm Mac-less at the moment, or - owning a powerbook -: powerless! )I like the lazarus name, btw (resurrecting from the dead, read the Bible for details). Leo |
|||||||||||||||||||
|
|
|
|
|
#8 | |||||||||||||||||||
|
Major Leaguer
Join Date: Jul 2002
Location: Germany
Posts: 441
|
Yep, that's the intention. I prefer to have my deleted files available in my thrashcan for recycling (you never know, as we have seen ). This does not help to restore files to their previous location, but at least they are still there.There are some drawbacks to this solution: - You should remember to empty the Trash from time to time - If you "del" two files with the same name, the first one is gone for good... - the first version makes you lose resource forks still, I found this a better way to "remove" files. cheers, pink
__________________
"And what have we got in here ? - Ahh, things.." (Louis (2), inspecting kitchen cupboards.) |
|||||||||||||||||||
|
|
|
|
|
#9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Triple-A Player
Join Date: Jul 2003
Location: Mierlo, Holland
Posts: 120
|
You can also store the complete path, by the equivalent of:
To overwrite a file this way, it had to be on the original spot in the filesystem anyway, so this isn't an issue. Note I would prefer to have a ${HOME}/.junkyard instead of ${HOME}/.thrash, since this avoids clashes with the standard thrashcan. Homework: write the del and undel commands as shell scripts. (not too hard: undel can do a find from the thrashcan location). Leo |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|
|
#10 |
|
Hall of Famer
Join Date: Sep 2003
Location: Tokyo
Posts: 4,419
|
I have heard (but never needed to try - knock knock) that it is possible to run grep on the /dev/hd~~ virtual directory and scan for the text you need. Sounds theoreticaly possible, but as it would be scanning the drive block by block be prepared for a loooooooong search and tons of junk output. I would also think that if you've used the drive for more than 10 minutes after the 'oops' that it's not worth the effort - save this for when you really need something, but don't want to drop $1000 on data recovery.
Now, do the following: Code:
for ($i=1; $i < 1000; $i++)
{
speak "I will make backups";
if (!$i % 10)
flog(self, "10baseT cable");
else flog(self, "wet noodle");
}
|
|
|
|
|
|
#11 | |||||||||||||||||||
|
Prospect
Join Date: Nov 2003
Posts: 19
|
I tried this but it didn't work for me. Perhaps because I'm using a bash shell? I did: alias del='/Developer/Tools/MvMac \!* ~/.Trash' touch ding del ding and i got the following: destination is a file but more than one source is specified (0) Any ideas? Thanks, Josh |
|||||||||||||||||||
|
|
|
|
|
#12 |
|
Triple-A Player
Join Date: Sep 2002
Location: los alamos
Posts: 96
|
see these two threads for scripts that rm files to the trash:
http://www.macosxhints.com/article.p...21018054958105 http://www.macosxhints.com/article.p...30217172653485 fxt |
|
|
|
|
|
#13 | |||||||||||||||||||
|
Major Leaguer
Join Date: Jul 2002
Location: Germany
Posts: 441
|
that should probably be Code:
alias del='/Developer/Tools/MvMac $* ~/.Trash' Code:
bash-2.05a$ alias foo='echo \!*' bash-2.05a$ foo bar !* bar bash-2.05a$ unalias foo bash-2.05a$ alias foo='echo $*' bash-2.05a$ foo bar bar Code:
alias del='/bin/mv $* /Users/pink/.Trash/' bash-2.05a$ touch ding bash-2.05a$ del ding /bin/mv: rename /Users/pink/.Trash/ to ding: Not a directory bash-2.05a$ unalias del bash-2.05a$ alias del='/bin/mv /Users/pink/.Trash/ $*' bash-2.05a$ del ding /bin/mv: rename /Users/pink/.Trash/ to ding: Not a directory cheers, pink
__________________
"And what have we got in here ? - Ahh, things.." (Louis (2), inspecting kitchen cupboards.) |
|||||||||||||||||||
|
|
|
|
|
#14 | ||||||||||||||||||||||||||||||||||||||
|
Moderator
Join Date: Jan 2002
Location: Montreal
Posts: 29,452
|
From the bash reference manual (http://www.faqs.org/docs/bashman/bashref_70.html):
|
||||||||||||||||||||||||||||||||||||||
|
|
|
|
|
#15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Triple-A Player
Join Date: Jul 2003
Location: Mierlo, Holland
Posts: 120
|
Such a function could be:
or
if you wanted to make sure. Since we already using functions, I would prefer to move it to a yet unused filename within ~/.Trash, and store the file's original location together with its new name, in an admin file. (This avoids clashes with already used names). For a lazarus function, it's then easy to restore the file to its original location. Leo |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|