ksaitoの日記

日々試したことの覚え書き

paxコマンド

移転しました。

自動的にリダイレクトします。

tarとcpioをサポートしたコマンドです。
fオプションでアーカイブファイルを指定します。
下記のようにzオプションでtarzip形式のファイルをリストすることができます。

$ sudo apt-get install pax
$ pax -zf apache-lenya-1.2.5-bin.tar.gz | head
apache-lenya-1.2.5-bin
apache-lenya-1.2.5-bin/legal
apache-lenya-1.2.5-bin/tools
apache-lenya-1.2.5-bin/tools/bin
apache-lenya-1.2.5-bin/tools/configure
apache-lenya-1.2.5-bin/tools/configure/lib
apache-lenya-1.2.5-bin/tools/configure/src
apache-lenya-1.2.5-bin/tools/configure/src/java
apache-lenya-1.2.5-bin/tools/configure/src/java/org
apache-lenya-1.2.5-bin/tools/configure/src/java/org/apache
$ 

下記のsオプションを使うとパスの置換ができるので結構使えそうです。

-s/パターン1/パターン2/

こんな感じで"-bin"のような配布側では必要ですが受け取り側では不要なパスを置換したりします。

$ pax -s/-bin// -zf apache-lenya-1.2.5-bin.tar.gz | head
apache-lenya-1.2.5
apache-lenya-1.2.5/legal
apache-lenya-1.2.5/tools
apache-lenya-1.2.5/tools/bin
apache-lenya-1.2.5/tools/configure
apache-lenya-1.2.5/tools/configure/lib
apache-lenya-1.2.5/tools/configure/src
apache-lenya-1.2.5/tools/configure/src/java
apache-lenya-1.2.5/tools/configure/src/java/org
apache-lenya-1.2.5/tools/configure/src/java/org/apache
$ 

パイプを使った入出力が基本でアーカイブする条件の指定も細かくできるので使い慣れればtarより便利そうです。