Linux: スワップファイル(swp)の削除方法




viでファイルを開いたときに「E325: ATTENTION」というメッセージが表示されるときがあります。

同時に同じファイルを編集しようとしているか、ファイルが壊れている場合に出るメッセージのようです。

例)

vi /etc/sysconfig/iptables

 
このようなメッセージが出ます。

E325: ATTENTION
Found a swap file by the name "/etc/sysconfig/.iptables.swp"
owned by: root dated: Tue Apr 24 09:29:25 2012
file name: /etc/sysconfig/iptables
modified: no
user name: hogehoge host name: example.com
process ID: 11949 (still running)
While opening file "/etc/sysconfig/iptables"
dated: Tue Apr 24 14:17:36 2012
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 /etc/sysconfig/iptables"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file "/etc/sysconfig/.iptables.swp"
to avoid this message.
"/etc/sysconfig/iptables" 39L, 1398C
E486: Pattern not found: etc
Press ENTER or type command to continue

(1)は他のプログラムが同じファイルを編集している可能性あり。

(2)はファイルが壊れていてスワップファイルが存在する場合。

スワップファイルは下記のように消せます。
 

# rm /etc/sysconfig/.iptables.swp
rm: remove 通常ファイル `/etc/sysconfig/.iptables.swp’? y

 
スワップファイルを戻したい場合は
 

#vi -r ファイル名




人気記事一覧


関連記事一覧

This entry was posted in Linux and tagged , , , . Bookmark the permalink.

コメントは受け付けていません。