LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   file became empty after edit mode need to retrieve its contents (http://www.linuxquestions.org/questions/linux-general-1/file-became-empty-after-edit-mode-need-to-retrieve-its-contents-4175452243/)

stonyuk 03-01-2013 09:00 AM

file became empty after edit mode need to retrieve its contents
 
I tried to open a file CW001.sql last night and then when tried to close it, it asked whether to save in .swp and dont know what i did now there is no contents in the file. Its empty. How can i retrieve the contents back. please help. Will recover or lsof command help? Advise with commands please.

Kustom42 03-01-2013 11:14 AM

If the contents of the file are gone they are gone. If there was a swap file with data in it you would get a message popping up telling you if you try to edit the file again and it would ask you to recover it. Otherwise the data is gone. You just learned a valuable lesson in backing up data, sorry man.

chrism01 03-04-2013 12:23 AM

As above, .swp files are editor backups while you've got it open. Try 'ls -a' in the correct dir; it might(!) be there.
Trying to edit a file of the original name may cause the editor to offer the .swp file if it exists.

fortran 03-04-2013 01:11 AM

See if the backup file is setting is ON or not.
It creates backup file automatically when you change in original as filename~.extension.
Check if the backup file is created.

Kustom42 03-04-2013 11:16 AM

Quote:

Originally Posted by pavi_kanetkar (Post 4904109)
See if the backup file is setting is ON or not.
It creates backup file automatically when you change in original as filename~.extension.
Check if the backup file is created.

What "backup" setting are you talking about? Is this something specific to VIM or Nano? << Thats a hint, yes it is. And by default it is not enabled. You must set the option in your .vimrc.


All times are GMT -5. The time now is 10:41 AM.