Http://www.cnblogs.com/ggjucheng/archive/2012/10/07/2714311.html
Unix/linux, the most dangerous command is probably the RM command, every time I use this command under root, I have to stare at the command line for a few minutes before I dare to knock the carriage return.
Previously, I saw colleagues using RM commands in Scripts-- rm {$App_Dir}/*
. Because the script does not determine whether the variable $app_dir is empty, as a result, in a single root operation, the entire operating system is gone, fortunately, just the development machine. Since then, we have all been afraid to use RM commands.
Here's a little tip for recovering data from some of the files that have been RM. We know that the RM command is not really a physical deletion of the file content, only the file inode is not recycled, in fact, the contents of the file is still on the hard disk.
So, if you do not small delete something more important program configuration file, we can fully use the grep command in the recovery, here is a recovery example:
Grep-a-B 50-a ' Some string in the file '/dev/sda1 > Results.txt
Description
- The-a meaning of grep is –binary-files=text, which is the binary file as a text file.
- The-B and-a options are the first few lines of the string and the next few lines.
- /DEV/SDA1, is the hard drive device,
- > results.txt is to redirect the results to the Results.txt file.
If you're lucky, you'll be able to see what's been restored.
Transfer from http://coolshell.cn/articles/2822.html
Use grep to recover deleted file contents "Go"