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 1 year has passed since last update.

Macでtarファイルを展開する方法

Last updated at Posted at 2022-11-01

概要

  • Macにてtarファイルを展開する方法をまとめる。

方法

  1. 展開にはtarコマンドを使う。tar -hの実行結果を下記に記載する。

    $ tar -h
    tar(bsdtar): manipulate archive files
    First option must be a mode specifier:
      -c Create  -r Add/Replace  -t List  -u Update  -x Extract
    Common Options:
      -b #  Use # 512-byte records per I/O block
      -f <filename>  Location of archive
      -v    Verbose
      -w    Interactive
    Create: tar -c [options] [<file> | <dir> | @<archive> | -C <dir> ]
      <file>, <dir>  add these items to archive
      -z, -j, -J, --lzma  Compress archive with gzip/bzip2/xz/lzma
      --format {ustar|pax|cpio|shar}  Select archive format
      --exclude <pattern>  Skip files that match pattern
      -C <dir>  Change to <dir> before processing remaining files
      @<archive>  Add entries from <archive> to output
    List: tar -t [options] [<patterns>]
      <patterns>  If specified, list only entries that match
    Extract: tar -x [options] [<patterns>]
      <patterns>  If specified, extract only entries that match
      -k    Keep (don't overwrite) existing files
      -m    Don't restore modification times
      -O    Write entries to stdout, don't restore to disk
      -p    Restore permissions (including ACLs, owner, file flags)
    bsdtar 3.5.1 - libarchive 3.5.1 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8
    
  2. 公式ドキュメントによるとtar -xvf 当該のtarファイルパスとすることで展開できる。(-xオプションは展開の指示、-vオプションは細かく状況を出力する指示、-fオプションはファイルを指定する指示)

    tar -xvf 当該のtarファイルパス
    

オチ

  • 実は今回、筆者が展開しようとしていたtarファイルはDockerイメージのtarファイルでした。Dockerイメージのtarファイルは展開せず、dockerにimportする必要があります。

参考文献

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?