34
Help us understand the problem. What are the problem?

posted at

updated at

Viで「E325:ATTENTIONエラー」の対処

はじめに

viでファイルを編集中にうっかりCtrl+Cコマンドで中断してしまったため、多重オープンしてしまった。対処方法をまとめた。

事象

vi で対象ファイルを開いたら次のようなメッセージが毎回出てしまう

--------------------------------------------- 
E325: ATTENTION 
Found a swap file by the name ".attention.sh.swp" 
 owned by: orenoscript dated: Tue Jan 01 00:01:00 2019 
 file name: /tmp/attention.sh 
 modified: YES 
 user name: root    host name: localhost.localdomain 
 process ID: 9999 
While opening file "attention.sh" 
 dated: Tue Jan 01 00:01:00 2019 
 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 atention.sh" 
 to recover the changes (see ":help recovery"). 
 If you did this already, delete the swap file ".atention.sh.swp" 
 to avoid this message. 
"attention.sh" 540L, 627C 
Press ENTER or type command to continue 
--------------------------------------------- 

対処

1.オープンしようとしているファイルのパスに移動
2.ls -laコマンドで該当スワップファイルを確認

drwxr-xr-x. 6 root   root   4096 Jan 01 00:01 .
drwxr-xr-x. 6 root   root   4096 Jan 01 00:01 ..
-rw-r--r--. 1 root   root  12288 Jan 01 00:01 .attention.sh.swo *
-rw-r--r--. 1 root   root  12288 Jan 01 00:01 .attention.sh.swp *
-rwxr-xr-x. 1 root   root   1383 Jan 01 00:01 .attention.sh

※マークのファイルがスワップファイル

3.rmコマンドでスワップファイルを削除

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
34
Help us understand the problem. What are the problem?