LoginSignup
40
36

More than 1 year has passed since last update.

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

Last updated at Posted at 2019-01-10

はじめに

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コマンドでスワップファイルを削除

40
36
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
40
36