Linux系统重新对时,Linux下vim编辑文件时对于上次意外退出的文件的再次开启编辑的解决方案...

1、当我们用远程工具连接Linux操作系统用vim编辑文件的时候,由于集群的不稳定,或打开后忘记关闭了,或非正常断开的时候。当我们再次编辑此文件的时候就会出现如下所示的提示:[root@localhost scripts]# vim rsync+inotify.sh

E325: ATTENTION

Found a swap file by the name ".rsync+inotify.sh.swp"

owned by: root   dated: Fri May 17 18:49:14 2019

file name: /server/scripts/rsync+inotify.sh

modified: YES

user name: root   host name: localhost.localdomain

process ID: 17081 (still running)

While opening file "rsync+inotify.sh"

dated: Fri May 17 18:45:31 2019

(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 rsync+inotify.sh"

to recover the changes (see ":help recovery").

If you did this already, delete the swap file ".rsync+inotify.sh.swp"

to avoid this message.

Swap file ".rsync+inotify.sh.swp" already exists!

[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

这是由于已经打开但未关闭的文件,会在其目录下出现一个.swp的文件,由于是属于隐藏文件,可以用命令“l.”对其进行查看。需要将该.swp文件进行删除,才不会出现上述中的那些提醒。

2、解决方案

查看并删除.swp隐藏文件[root@localhost scripts]# l.

.  ..  .rsync+inotify.sh.swp

[root@localhost scripts]# rm -rf .rsync+inotify.sh.swp

由于是隐藏的文件,所以不能够使用rm -rf *.swp这样的形式进行删除;

但是可以使用语句:rm -rf .*.swp  的形式进行删除

删除该文件的.swp隐藏文件之后就可以正常打开和编辑该文件了。[root@localhost scripts]# vim rsync+inotify.sh

#!/bin/bash

#qq:1431975440

#rsync+inotify

serverID=10.90.3.115

back_path=/data

rsync_module=oldboy

rsync_user=rsync_backup

rsync_passwd=/etc/rsync.password

inotify_path=/opt/inotify/bin/inotifywait

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值