Linux中.swp 文件的产生与解决方法

2024-10-14 12:01:36

1、我们使用vi命令编辑nginx.conf配置文件,出现如图提示,此时我们也可以直接按E键进行正常进行编辑,但是下次还是可能出现。那么产生此问题的原因是什么。如下是两种情况会产生(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 nginx.conf" to recover the changes (see ":help recovery"). If you did this already, delete the swap file ".nginx.conf.swp" to avoid this message解释一下,出现这种情况是此文件产生了交换文件,即后缀为.swp的文件1:当我们编辑一个文件的时候,另外一个人也在编辑的时候,会出现2:当我们编辑文件时候,突然断电,或者突然断网,为了防止数据丢失,也会出现这种文件

Linux中.swp 文件的产生与解决方法

3、当产生此文件时,我们可以直接rm -f.nginx.conf.swp删除此swp文件,否者每次编辑就会出现提示,但是如果是在文件编辑之后,出现非正常退出,此时我们的配置并没有保存在nginx.conf文件中,我们需要使用vi -r nginx.conf进行恢复,如图进行文件恢复,然后回车,配置就会从.swp中恢复到nginx.conf中,然后再删除.swp文件

Linux中.swp 文件的产生与解决方法
猜你喜欢