Tar
tar -C option
tar コマンドの -C オプションを使用してアーカイブを作成する際の要点をまとめます:
tar -cvf archive.tar -C /path/to/directory/ files
-Cオプション: 指定したディレクトリに移動してからアーカイブを作成する。/path/to/directory/: 移動したいディレクトリのパス。files: アーカイブに含めるファイルやディレクトリ。- アーカイブファイル (
archive.tar) は現在の作業ディレクトリに作成される。
extraction
展開のファイル指定
mkdir sb
cd ${_}
touch raw{0..3}
tar zcvf data.tar.gz r*
rm r*
tar xvf data.tar.gz raw2
## => raw2
Compression options
| z | gzip |
| j | bzip2 |
| J | xz |
ファイルを残さないパターン(ディレクトリは不可)
/tmp/compress xz a b c; ls -1
a.xz
b.xz
c.xz
/tmp/compress
ファイルを残すパターン
/tmp/compress tar cJf all.tar.xz a b c; ls -1
a
all.tar.xz
b
c
/tmp/compress