Writing to Standard Output (GNU tar 1.34)

Next: Writing to an External Program, Previous: Directory Modification Times and Permissions, Up: Writing [Contents][Index]

#### Writing to Standard Output

To write the extracted files to the standard output, instead of creating the files on the file system, use `--to-stdout` (`-O`) in conjunction with `--extract` (`--get`, `-x`). This option is useful if you are extracting files to send them through a pipe, and do not need to preserve them in the file system. If you extract multiple members, they appear on standard output concatenated, in the order they are found in the archive.

`--to-stdout`
`-O`

  Writes files to the standard output. Use only in conjunction with `--extract` (`--get`, `-x`). When this option is used, instead of creating the files specified, `tar` writes the contents of the files extracted to its standard output. This may be useful if you are only extracting the files in order to send them through a pipe. This option is meaningless with `--list` (`-t`).

This can be useful, for example, if you have a tar archive containing a big file and don’t want to store the file on disk before processing it. You can use a command like this:

    tar -xOzf foo.tgz bigfile | process

or even like this if you want to process the concatenation of the files:

    tar -xOzf foo.tgz bigfile1 bigfile2 | process

However, `--to-command` may be more convenient for use with multiple files. See the next section.