R.A. Epigonos et al.

[linux] tarでCannot connect to hoge:fuga.tar resolve failedエラーの解決法

問題はfオプションで与えたtarファイルのファイルパスにコロン(:)が含まれること。このような場合はtarは自動的にrshホスト上のファイルを探しに行く。ファイル名に:が含まれる場合はローカルのパスであることを明示するためにファイルパスを./等から始めるか、 --force-localオプションを使う。

例えばhoge.txtをhoge:fuga.tarというファイルに纏めたい場合、以下のようにすると期待したとおりに動かない。エラーが出ている。

$ tar cvf hoge:fuga.tar hoge.txt
tar: Cannot connect to hoge: resolve failed

以下のようにして、ファイル名を./から始めればエラーは出ない。正しく作成できていることを確認。

$ tar cvf ./hoge:fuga.tar hoge.txt
hoge.txt
$ tar tvf ./hoge\:fuga.tar
-rw-r--r-- hoge/hoge      3116 2011-04-09 08:48 hoge.txt

もう1つの解決策として、--force-localオプションを使う方法がある。このときは必須オプションのつけ方に注意。ハイフンを付けないとエラーが出る。

$ tar --force-local cvf hoge:fuga.tar hoge.txt
tar: You must specify one of the `-Acdtrux' or `--test-label'  options
Try `tar --help' or `tar --usage' for more information.
$ tar --force-local -cvf hoge:fuga.tar hoge.txt
hoge.txt
$ tar --force-local -tvf hoge\:fuga.tar
-rw-r--r-- hoge/hoge      3116 2011-04-09 08:48 hoge.txt

どうやらコロンに関する問題はあまりに当然過ぎてMLでも無視される傾向にあるみたいだ。

リファレンス

  1. ファイル名にコロンを含んだtarファイルを展開 « Siguniang's Blog
  2. tar コロン - Google 検索
  3. Linuxサーバ設定備忘録-Linuxコマンド-【tar】
  4. tar.gzファイルの圧縮・解凍 [Fedora, RedHat, CentOS] - Linux
  5. tar - UNIX/Linuxコマンド - IT専科
  6. Man page of TAR
  7. tar colon - Google 検索
  8. [Bug-tar] colon in archive name
  9. Re: [Bug-tar] colon in archive name

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2009-11-29T18:44:40+09:00
  2. Modified: 2009-11-29T18:44:40+09:00
  3. Generated: 2023-08-27T23:09:13+09:00