LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Unexpected message (http://www.linuxquestions.org/questions/linux-software-2/unexpected-message-4175437879/)

Huamin 11-19-2012 08:58 PM

Unexpected message
 
Hi,
When use vi to edit any one file, I get this
E325: ATTENTION
Found a swap file by the name "/etc/.hosts.swp"
owned by: root dated: Fri Nov 16 09:25:07 2012
file name: /etc/hosts
modified: no
user name: root host name: localhost.localdomain
process ID: 4126
While opening file "/etc/hosts"
dated: Mon Nov 19 23:37:42 2012
NEWER than swap file!

(1) Another program may be editing the same file.
If this is the case, be careful not to end up with two
different instances of the same file when making changes.
Quit, or continue with caution.

(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r /etc/hosts"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file "/etc/.hosts.swp"
to avoid this message.
"/etc/hosts" 4L, 192C
Press ENTER or type command to continue

Why?

Many Thanks & Best Regards,
HuaMin

catkin 11-19-2012 09:20 PM

For the one of the reasons in the message.

Huamin 11-19-2012 10:49 PM

There is no one editing that. Why does the OS say it is crashed?

Berhanie 11-20-2012 12:47 AM

it's possible that you did not exit the editor properly, so that the .swp file was not deleted. one reason for this may be that you accidentally hit ctrl-z (suspend process) while editing a file. this is a common problem, as i've observed, with people new to linux. you can see your suspended jobs with the "jobs" command, and can un-suspend the last job by putting it in the foreground again with the "fg" command. this all needs to happen before you log out and thereby (probably) kill those jobs.

if you cannot resume your editing session as above, you can follow the the instructions of the error message, and attempt to recover your changes with "vi -r", or just remove the .swp file (with "rm /path/to/.swp/file") and work with the file that you have saved.

in future, you might make the subject of your thread more descriptive, e.g. "vim swap file prevents editing" rather than "unexpected message".

Huamin 11-20-2012 01:29 AM

Thanks. I don't see .swp file inside the relevant folder. Where is the .swp file?

Berhanie 11-20-2012 01:49 AM

Quote:

Thanks. I don't see .swp file inside the relevant folder. Where is the .swp file?
the error message says the swap file is /etc/.hosts.swp. you should be able to see with "ls -a /etc". you can examine it with "less" or "cat".


All times are GMT -5. The time now is 12:56 PM.