首页 > 编程知识 正文

linux find命令找文件内容,linux修改文件使文件不能被修改

时间:2023-05-05 10:21:19 阅读:200969 作者:2205

修改linux文件之后,文件不可编辑怎么办?

秩名发表于 2019-04-16 20:02次浏览

使用远程连接工具,在linux系统下,使用vi命令操作文件,如jsp,js,txt等文件,不小心操作错误导致任何指令都不可用,如习惯性使用ctrl+s进行保存。

在这种情况可以直接关闭远程连接,再次连接。到之前的文件所在目录下。

使用vi test.txt 将会出现提示:

E325: ATTENTION

Found a swap file by the name ".test.txt.swp"

owned by: root   dated: Tue Dec 25 14:21:27 2018

file name: /home/qycn_jabk/jabk_bak/test.txt

modified: YES

user name: root   host name: localhost.localdomain

process ID: 31935

While opening file "test.txt"

dated: Tue Dec 25 14:16:22 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 test.txt"

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

If you did this already, delete the swap file ".test.txt.swp"

to avoid this message.

由提示内容可知,造成该情况原因有二:

一、该文件有别的人在操作,该情况下请退出操作;

二、该文件的编辑会话崩溃;

如果确认咱们遇到的是第二种情况,提示内容也给出了解决方法:

1、在vi命令模式下使用“:revocer”可以恢复之前的操作

2、可以使用vi -r test.txt命令操作文档也可以恢复之前的操作

如果不想要恢复之前的操作,可以文件所在的目录,使用ll -a命令,

可以看到目录下多了一个.test.txt.swp的文件,将该文件删除即可进行恢复到操作之前的内容,进行重新编辑。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。