2

I deleted my file content in the file how can i recover back using timestamps is it possible for ex: I am having the file1.txt

cat file1.txt 
i am linux user 
i am new to linux 
i love linux 

After sometime i later i delete the file content

cat file1.txt 
empty: 

how to get back the content again in the file

3

Depends how you edited / deleted and how many times the content. Some editors like gedit creates a backup copy of file before saving with the '~' (tilde) suffix. These files with the '~' suffix are hidden files for most of file managers (like Nautilus). So, with a little bit of luck you can recovery your lost content from these files.

| improve this answer | |
  • Thanks but ,i don’t have gedit i am using vi editor could tell me these editor also create file in same way – Premkumar Mar 15 '14 at 13:10
  • @Premkumar Sorry to inform you, but by default vi doesn't create backup files. You can see this guidelines about how you can make vi to store backups of the file you are editing. – Radu Rădeanu Mar 15 '14 at 13:37
0

Backup file for some text document files will be automatically created if it was opened using gedit text editor.Which was hidden and it ends with ~.By default this text document backup option was enabled.If you dont want gedit to create any backups.Then you can disable this option from,

Gedit-->Edit-->Preferences-->Editor

enter image description here

To ensure it's presence try ls command after cding into the current directory.If it was located, then copy its contents to the main file by running the below command,

cat file1.txt~ > file1.txt
| improve this answer | |
  • thanks but i don’t have GUI ,then how can i do that enabling, can i do that in command line is there any command and also i am not having gedit – Premkumar Mar 15 '14 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.