Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use grep to recover mistakenly deleted text files by linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use grep to recover deleted text files in linux", the explanation in the article is simple and clear, easy to learn and understand, please follow the ideas of Xiaobian slowly, together to study and learn "how to use grep to recover deleted text files in linux"!

First create a temporary text file vpsee.log for testing, and then delete this file:

$ echo "important log file for vpsee.com" > vpsee.log

$ cat vpsee.log

important log file for vpsee.com

$ rm vpsee.log If you can remember a keyword in the file you just deleted, you can use grep to search the entire/dev/sda1, the-a flag means to treat the partition/dev/sda1 as text (the partition itself is binary), and the-B 10 -A 100 means to print the first 10 and last 100 lines of the keyword if you find it:

# grep -a -B 10 -A 100 'vpsee.com' /dev/sda1 > tmp.txt Find what we just deleted among the @:

$ vi tmp.txt

...

@$^@^@^@^@^@^@^@^@^@^@^@^A^@^@^@^@^@^@^@Ç^@^@^@^A^@^@^@^@^@^@^@^@^@^@^@È^K^@^@^@

^@^@^@^@^@^@^@^@^@^@^@^A^@^@^@^@^@^@^@^Q^@^@^@^C^@^@^@^@^@^@^@^@^@^@^@È^K^@^@×^@

^@^@important log file for vpsee.com

@

@

... Of course, if you delete binary, doc, png/jpg/gif files by mistake, you can use some third-party ext2/ext3 file recovery tools to help recover files, such as TestDisk, PhotoRec, etc.

Thank you for reading, the above is "linux how to use grep to recover deleted text files" content, after the study of this article, I believe that everyone on linux how to use grep to recover deleted text files this problem has a deeper understanding, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report