tar: Writing to an External Program
1
1 Writing to an External Program
1 ..............................
1
1 You can instruct 'tar' to send the contents of each extracted file to
1 the standard input of an external program:
1
1 '--to-command=COMMAND'
1 Extract files and pipe their contents to the standard input of
1 COMMAND. When this option is used, instead of creating the files
1 specified, 'tar' invokes COMMAND and pipes the contents of the
1 files to its standard output. The COMMAND may contain command line
1 arguments (see ⇒Running External Commands external, for more
1 detail).
1
1 Notice, that COMMAND is executed once for each regular file
1 extracted. Non-regular files (directories, etc.) are ignored when
1 this option is used.
1
1 The command can obtain the information about the file it processes
1 from the following environment variables:
1
1 'TAR_FILETYPE'
1 Type of the file. It is a single letter with the following
1 meaning:
1
1 f Regular file
1 d Directory
1 l Symbolic link
1 h Hard link
1 b Block device
1 c Character device
1
1 Currently only regular files are supported.
1
1 'TAR_MODE'
1 File mode, an octal number.
1
1 'TAR_FILENAME'
1 The name of the file.
1
1 'TAR_REALNAME'
1 Name of the file as stored in the archive.
1
1 'TAR_UNAME'
1 Name of the file owner.
1
1 'TAR_GNAME'
1 Name of the file owner group.
1
1 'TAR_ATIME'
1 Time of last access. It is a decimal number, representing seconds
1 since the Epoch. If the archive provides times with nanosecond
1 precision, the nanoseconds are appended to the timestamp after a
1 decimal point.
1
1 'TAR_MTIME'
1 Time of last modification.
1
1 'TAR_CTIME'
1 Time of last status change.
1
1 'TAR_SIZE'
1 Size of the file.
1
1 'TAR_UID'
1 UID of the file owner.
1
1 'TAR_GID'
1 GID of the file owner.
1
1 Additionally, the following variables contain information about tar
1 mode and the archive being processed:
1
1 'TAR_VERSION'
1 GNU 'tar' version number.
1
1 'TAR_ARCHIVE'
1 The name of the archive 'tar' is processing.
1
1 'TAR_BLOCKING_FACTOR'
1 Current blocking factor (⇒Blocking).
1
1 'TAR_VOLUME'
1 Ordinal number of the volume 'tar' is processing.
1
1 'TAR_FORMAT'
1 Format of the archive being processed. ⇒Formats, for a
1 complete list of archive format names.
1
1 These variables are defined prior to executing the command, so you
1 can pass them as arguments, if you prefer. For example, if the command
1 PROC takes the member name and size as its arguments, then you could do:
1
1 $ tar -x -f archive.tar \
1 --to-command='proc $TAR_FILENAME $TAR_SIZE'
1
1 Notice single quotes to prevent variable names from being expanded by
1 the shell when invoking 'tar'.
1
1 If COMMAND exits with a non-0 status, 'tar' will print an error
1 message similar to the following:
1
1 tar: 2345: Child returned status 1
1
1 Here, '2345' is the PID of the finished process.
1
1 If this behavior is not wanted, use '--ignore-command-error':
1
1 '--ignore-command-error'
1 Ignore exit codes of subprocesses. Notice that if the program
1 exits on signal or otherwise terminates abnormally, the error
1 message will be printed even if this option is used.
1
1 '--no-ignore-command-error'
1 Cancel the effect of any previous '--ignore-command-error' option.
1 This option is useful if you have set '--ignore-command-error' in
1 'TAR_OPTIONS' (⇒TAR_OPTIONS) and wish to temporarily cancel
1 it.
1