Use grep to recover deleted file contents "Go"

Source: Internet
Author: User

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"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.