当我们通过vi编辑一个文件时,偶尔会遇到如下提示,比如我vi log时提示如下:
Found a swap file by the name ".log.swp"
owned by: root dated: Wed Feb 28 16:52:13 2018
file name: /alidata1/log
modified: YES
user name: root host name: iZbp181cltiu5c1q55bbr1Z
process ID: 119 (still running)
While opening file "log"
dated: Wed Feb 28 16:52:04 2018
(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 log"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file ".log.swp"
to avoid this message.
"log" 0L, 0C
Press ENTER or type command to continue
大意就是发现了一个叫做“.log.swp”的文件,什么原因呢?
swp即swap的缩写,交换的意思,swp文件都是隐藏文件。比如原文件名是log,那么swp文件名就是.log.swp。当你使用vi编辑log时,就会产生.log.swp,如果log文件编辑完成正常退出,那么对应的swp文件会自动删除。但如下两种情况不会删除swp文件:
-
非正常退出,此时,只能手动删除swp文件了。
-
多个程序同时编辑一个文件时也会出现如上提示