揮発性のメモ2

知識をメモ書きしておく

tarで、ファイルをひとつだけ解凍する

今は解凍とは言わず展開と言います。

hoge
`-- tool
    `-- hello.sh

これを /tmp の直下に hello.sh だけ展開したいときは、次のようにする

tar zxf /tmp/hoge.tar.gz -C /tmp/ --strip-components=2 hoge/tool/hello.sh
zxf 今は z はいらない
-C /tmp/ 作業前に そこに cd するようなイメージ
--strip-components=2 展開時、この指定数だけディレクトリを削る
hoge/tool/hello.sh 展開したいファイル。指定により、ディレクトリは2個削られる