0
2

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.

tarコマンドのまとめ

Posted at

LPICを勉強している際、tarコマンドについて気になったのでまとめます。

参考記事

【 tar 】コマンド――アーカイブファイル...

特徴

・アーカイブを作成するコマンド
・オプションを-なしで指定できる
・gzip,xz,bzip2などを解凍/圧縮できる(拡張子はgz,tgz,xz,bz2など)

オプション説明

ベタなやつだけ。

操作系

-c : アーカイブ新規作成。
-t : 指定したアーカイブの内容を表示。
-x : アーカイブからファイルを抽出。

共通

-f : アーカイブ名を指定。
-v : 処理を詳しく表示。
-z : gzip形式を圧縮/展開。
-J : xz形式を ” 。
-j : bzip2形式を ” 。
-Z : compress形式を ” 。
--lzma : lzma形式を ” 。

ユースケース

例えばgzip形式で圧縮するには下記のようなコマンドを実行し、

tar zcf <new archive name> <target name>

gzip形式を展開するには、

gzip -d <name> / gunzip <name> / tar zxf <name>

のいずれかを実行する必要がある。( fオプションを指定しないと処理が進まなかった。)

まとめ

オプションがいっぱいあるからその都度 -h を見るか、調べた方がいい気がする。
(tar -h は簡易的な説明のみ書かれている。)
man tar なら詳しく説明されているので状況によってはこっちのほうがいいかも。

0
2
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
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?