2
3

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 5 years have passed since last update.

tar の使い方まとめ

Posted at

とりまこれで必要十分

急いで tar しなきゃいけないときは脳死してこれを使います

圧縮

% tar -czf <ファイル名>.tgz <ディレクトリ名>

解凍

% tar -xf <ファイル名>.tgz

備考

寡黙なデキるヤツ

以下はオプション

最高級版

圧縮

% tar -cvzf <ファイル名>.tgz <ディレクトリ名>

解凍

% tar -xvzf <ファイル名>.tgz

備考

逐一報告は有り難いけどファイルが多いとちょっとうるさいかも
あと解凍時の -z は実は不要

最軽量版

まとめる

% tar -cf <ファイル名>.tar <ディレクトリ名>

ばらす

% tar -xf <ファイル名>.tar 

備考

ミニマリストにオススメ
でも圧縮後はミニマルじゃない

一番普通版

まとめる

% tar -cvf <ファイル名>.tar <ディレクトリ名>

ばらす

% tar -xvf <ファイル名>.tar

備考

ノーマルなタイプ

解説

各フラグの役割

-c: Create archive
-f: path to Files or directories to archive
-v: Verbosely show the .tar file progress.
-x: eXtract
-z: Zip
  • -c は束ねる (create)
  • -x は元に戻す (extract)
  • -f はファイル(かディレクトリ)指定 (file)
  • -v はあってもなくても良い報告担当 (verbosely)
  • -z は圧縮解凍

なんとか暗記する

  • 圧縮には create で c
  • 解凍には extract で x
  • なんか絶対に必要なやつあったな、file の f だ
  • verboseなんとかみたいなうるさい単語あったな、けどサクッとやってほしいからいらない
  • どうせなら zip しとくか、z だ
  • 圧縮なら create で、file 指定して、zip しよか、-czf だ!うん、語感も記憶と近い気がする!
  • 解凍なら extract で、file 指定して、zip 解除だな、あ、解凍で z フラグ使うのはオジサンだけとかいう話聞いたことあるな笑、じゃあ要らないや、よし -xf だ!うん、2文字くらいだった気がする

免責

フラグの順序に関する宗教戦争については、一切の責任を負いかねます。

2
3
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?