1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

圧縮・解凍コマンド

Last updated at Posted at 2020-02-28
圧縮形式 圧縮コマンド 解凍コマンド
tar.gz tar zcvf ${archive_name}.tar.gz data/ tar zxvf ${archive_name}.tar.gz
tar.bz2 tar jcvf ${archive_name}.tar.bz2 data/ tar jxvf ${archive_name}.tar.bz2
tar.xz tar Jcvf ${archive_name}.tar.xz data/ tar Jxvf ${archive_name}.tar.xz
zip zip -r ${archive_name}.zip data/ unzip ${archive_name}.zip
zip(pass) zip -re ${archive_name}.zip data/ unzip ${archive_name}.zip
tarオプション 説明
-z, --gzip アーカイブを gzip で圧縮
-j, --bzip2 アーカイブを bzip2 で圧縮
-J, --xz アーカイブを xz で圧縮
-c, --create 新しいアーカイブを作成
-x, --extract アーカイブからファイルを抽出
-v, --verbose 圧縮/解凍処理したファイルのリストを出力
-f, --file 圧縮先/解凍元アーカイブを指定

494Mのデータを圧縮

圧縮形式 圧縮後 圧縮時間 解凍時間  
tar.gz 164M 1m10.696s 0m10.876s
tar.bz2 143M 1m31.335s 0m26.851s
tar.xz 96M 4m22.670s 0m12.855s
zip 302M 1m22.144s 0m15.039s
zip(pass) 302M 1m33.685s 0m23.371s

履歴

#--------------------------------------------
# テストデータ
#--------------------------------------------
yum -y --releasever=7 --installroot=/var/lib/machines/centos7 install systemd passwd yum
$ du -sh /var/lib/machines/centos7
494M	/var/lib/machines/centos7

#--------------------------------------------
# 圧縮
#--------------------------------------------
cd /var/lib/machines
time tar zcvf centos7.tar.gz centos7/
time tar jcvf centos7.tar.bz2 centos7/
time tar Jcvf centos7.tar.xz centos7/
time zip -r centos7.zip centos7
time zip -r centos7p.zip centos7

#--------------------------------------------
# 解凍
#--------------------------------------------
mkdir -p /tmp/test/{gz,bz2,xz,zip,zipp}
time tar zxvf centos7.tar.gz -C /tmp/test/gz/
time tar jxvf centos7.tar.bz2 -C /tmp/test/bz2/
time tar Jxvf centos7.tar.xz -C /tmp/test/xz/
time unzip centos7.zip -d /tmp/test/zip/
time unzip centos7p.zip -d /tmp/test/zipp/

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?