LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 03-01-2013, 10:00 AM   #1
stonyuk
LQ Newbie
 
Registered: Feb 2013
Posts: 3

Rep: Reputation: Disabled
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.
 
Old 03-01-2013, 12:14 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,590

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
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.
 
Old 03-04-2013, 01:23 AM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,311

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
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.
 
Old 03-04-2013, 02:11 AM   #4
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 50
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.
 
Old 03-04-2013, 12:16 PM   #5
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,590

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Quote:
Originally Posted by pavi_kanetkar View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to edit a file in grub mode san4fun2004 Linux - Laptop and Netbook 3 06-11-2010 02:44 PM
How edit file with grub mode eng_mohammedmostafa Linux - Software 17 04-27-2010 09:38 AM
Edit file from Rescue Mode? tdog Linux - General 3 10-29-2005 02:59 PM
Edit file in rescue mode DanielTan Linux - Newbie 1 09-19-2004 12:44 PM
Edit a file in single-user mode ricardocastro Linux - Software 2 02-26-2002 05:37 PM


All times are GMT -5. The time now is 05:41 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration