_                    _
  ___ | |__   __ _ _______ | |_
 / _ \| '_ \ / _` |_  / _ \| __|
| (_) | | | | (_| |/ / (_) | |_
 \___/|_| |_|\__,_/___\___/ \__|

tararchive tool: usage

tar -[v][zj][xc]f TAR_FILE [DIRECTORY|DIRECTORY/*]
If DIRECTORY is not specified, when extracting, it's extracted to the current directory.

-c : compress
-x : extract
-v : verbose
-f TAR_FILE : use specified TAR_FILE
-z : use gzip compression
-j : use bzip2 compression
-t : list archive contents
-C DIR : cd to directory

The options can be collapsed but f needs to be the last option. Eg.:

tar -zvxf tar_file

- Filename(s) can be specified to extract only specified file(s).
- The full path inside the tar file needs to be specified.

d1/file1 d2/file2 $ tar -zxf tar_file d1/file1

  • Compress the contents of dir_to_compress located in parent_directory into dir.tar.gz.
    $ pwd
    cur_directory
    $ ls parent_directory
    dir_to_compress
    $ tar -C parent_directory -zcf dir.tar.gz dir_to_compress
    $ ls
    parent_directory dir.tar.gz
  • Extract the contents of TAR_FILE into EXTRACT_DIR.
    $ tar -C EXTRACT_DIR -zxf TAR_FILE

(back to top)

- Translate to Spanish.

(back to top)

OpenBSD manpages: tar(1)

(back to top)

2025-10-03 : Created.

(back to top)

ohazot | about | ohazot.com <admin@ohazot.com>

This document applies to: OpenBSD 7.7 linux| 2026-03-24