diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-11-23 23:53:29 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-11-23 23:53:29 (GMT) |
commit | d27b455bbcedd232ad8490acff46f532a365be49 (patch) | |
tree | f81a8c6bf695aba1bf93e030a3a25b29a845f140 /Doc | |
parent | 44e2eaab5491881120aab43e2838da8afe7ab70e (diff) | |
download | cpython-d27b455bbcedd232ad8490acff46f532a365be49.zip cpython-d27b455bbcedd232ad8490acff46f532a365be49.tar.gz cpython-d27b455bbcedd232ad8490acff46f532a365be49.tar.bz2 |
Issue #13477: Added command line interface to the tarfile module.
Original patch by Berker Peksag.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/tarfile.rst | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst index b8b65b9..d7e3b5f 100644 --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -591,6 +591,67 @@ A :class:`TarInfo` object also provides some convenient query methods: Return :const:`True` if it is one of character device, block device or FIFO. +.. _tarfile-commandline: + +Command Line Interface +---------------------- + +.. versionadded:: 3.4 + +The :mod:`tarfile` module provides a simple command line interface to interact +with tar archives. + +If you want to create a new tar archive, specify its name after the :option:`-c` +option and then list the filename(s) that should be included:: + + $ python -m tarfile -c monty.tar spam.txt eggs.txt + +Passing a directory is also acceptable:: + + $ python -m tarfile -c monty.tar life-of-brian_1979/ + +If you want to extract a tar archive into the current directory, use +the :option:`-e` option:: + + $ python -m tarfile -e monty.tar + +You can also extract a tar archive into a different directory by passing the +directory's name:: + + $ python -m tarfile -e monty.tar other-dir/ + +For a list of the files in a tar archive, use the :option:`-l` option:: + + $ python -m tarfile -l monty.tar + + +Command line options +~~~~~~~~~~~~~~~~~~~~ + +.. cmdoption:: -l <tarfile> + --list <tarfile> + + List files in a tarfile. + +.. cmdoption:: -c <tarfile> <source1> <sourceN> + --create <tarfile> <source1> <sourceN> + + Create tarfile from source files. + +.. cmdoption:: -e <tarfile> [<output_dir>] + --extract <tarfile> [<output_dir>] + + Extract tarfile into the current directory if *output_dir* is not specified. + +.. cmdoption:: -t <tarfile> + --test <tarfile> + + Test whether the tarfile is valid or not. + +.. cmdoption:: -v, --verbose + + Verbose output + .. _tar-examples: Examples |