News for hackers. Stuff that matters.
Re:Recovering deleted files using only grep by a3_nm on Wednesday June 25, 2014 @01:34PM (#7945488)
How could this work? I would expect this method to yield a bunch of matches corresponding to every version of the file that was once saved and continues to live on the disk. Unless you happen to have a string that only existed in the last version or so, but that's hard to come by...

I once did recovery of this kind for a friend (using, I think, photorec or extundelete, not grep) and the hardest part by far was piecing together the "right" version of the files from all matching versions that were recovered from disk.

Re:Recovering deleted files using only grep by danielweber on Wednesday June 25, 2014 @01:53PM (#7945612)
I don't think there are any guarantees here, but if he kept on saving the same file with the same name, it probably overwrote the same sector on disk.
Re:Recovering deleted files using only grep by a3_nm on Wednesday June 25, 2014 @06:24PM (#7947109)
I guess it depends on the text editor. Some editors will save new versions of a file with the same name by writing the current buffer to a new file and then atomically moving that file to the target location, which has no reason to write on the same sectors.
Re:Recovering deleted files using only grep by rnicholson on Wednesday June 25, 2014 @06:52PM (#7947217)
What is the reason for saving then moving for existing files? This an optimization specific to certain file systems?
Re:Recovering deleted files using only grep by samdk on Wednesday June 25, 2014 @09:07PM (#7947629)
Moving a file (within the same file system) is an atomic operation on most file systems, but writing data is not.

If you don't do this and you're overwriting a file directly and the write fails for some reason, the data from the old file will be gone and you'll only have a partially-written new file in its place.

This also helps with systems that continuously poll files and watch for changes. If you have, say, a compiler watching your file, you don't want it to start compiling a partially-written version of your file and give you some strange error just because it happened to poll before the write finished.

Re:Recovering deleted files using only grep by WalterBright on Wednesday June 25, 2014 @07:14PM (#7947299)
So if there's a write failure the user won't lose his file.