2009年10月31日土曜日

tar ball からファイルの取り出し

tar ball からファイルの取り出し

tar ball (*.tar.gz) から必要なファイルだけを取り出します。
例としまして autorespond-2.0.2.tar.gz からソースファイルを取り出します。

対象の tar ball に含まれるファイルを確認します。 tar コマンドの -t オプションを使用します。

$ tar -ztf autorespond-2.0.2.tar.gz
autorespond-2.0.2/
autorespond-2.0.2/README
autorespond-2.0.2/autorespond.c
autorespond-2.0.2/help_message
autorespond-2.0.2/qmail-auto
autorespond-2.0.2/Makefile

引き数に取り出すファイル (ディレクトリ) 名を指定して tar コマンドを実行します。

$ tar -zxf autorespond-2.0.2.tar.gz autorespond-2.0.2/autorespond.c

コマンド実行後、カレントディレクトリに引き数に指定したファイルだけが展開されます。

$ find .
.
./autorespond-2.0.2.tar.gz
./autorespond-2.0.2
./autorespond-2.0.2/autorespond.c

./autorespond-2.0.2/autorespond.c を取り出して操作は完了です。

http://www.freewheelburning.com/linux/misc.html#tar_t

0 件のコメント: