Tuesday, December 6, 2011

Solaris: undelete file

How to undelete any open, deleted file on linux / solaris

This works on Solaris as well.  =)
$:~:uname -a
SunOS somehost.com 5.10 Generic_127112-11 i86pc i386 i86pc
$:~:echo “sup prefetch.net folks?” > testfile
$:~:tail -f testfile &
[1] 17134
$:~:rm testfile
$:~:ls /proc/17134/fd/
0  1  2
$:~:cat /proc/17134/fd/0
sup prefetch.net folks?
$:~:cp !$ ./testfile
cp /proc/17134/fd/0 ./testfile
$:~:cat testfile
sup prefetch.net folks?