# # This is in the language Tcl. # Usage: # tclsh scriptname < /dev/hda1 (the partition with the deleted file) # # Notice: change the MOUNT below to a different partition! # # Also fix the "string match" pattern -- we used \document for a LaTeX document. # # Occasinally sector numbers are written out, to indicate progress. # ( 1 sector == 512 bytes == 0.5KBytes ) set i 0 set n 0 fconfigure stdin -translation binary -encoding binary while true { set x [read stdin 512 ] if {$x==""} break if {[string match {\\document*} $x ]} { incr i puts stderr "SAVING $i" set f [open /WRITABLE_MOUNT_TO_SAVE_FILES_IN_GOES_HERE/rescue.$i w] fconfigure $f -translation binary -encoding binary puts -nonewline $f $x puts -nonewline $f [read stdin [expr 600*512] ] close $f } incr n if { ($n % 200000)==0 } { puts -nonewline stderr $n. } }