Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

はじめに

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

事象

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

--------------------------------------------- 
E325: ATTENTION 
Found a swap file by the name ".attention.sh.swp" 
 owned by: yasushisatou 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

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

  1. rmコマンドでスワップファイルを削除
elu_jaune
2000年頃にITエンジニアデビュー。 solaris、windowsのインフラ管理を3年経験。 ajax、pearが出始めた頃にphpプログラミングを2年経験。 Windows Server OSをメインに活動して早13年。 久しぶりにlinuxを触ることになったのでlinuc取得に向けて勉強中。
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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした