SYNOPSIS
tar [OPTION...] [FILE]...
DESCRIPTION
GNU `tar' saves many files together into a single tape or disk archive, and can restore individual files from the archive.
GNU `tar' saves many files together into a single tape or disk archive, and can restore individual files from the archive.
Note that this manual page contains just very brief description (or more like a list of possible functionality) originally generated by the help2man utility. The full documentation for tar is maintained as a Texinfo manual. If the info and tar programs
are properly installed at your site, the command `info tar' should give you access to the complete manual.
EXAMPLES
tar -cf archive.tar foo bar
# Create archive.tar from files foo and bar.
tar -tvf archive.tar
# List all files in archive.tar verbosely.
tar -xf archive.tar
# Extract all files from archive.tar.
DEFAULTS
*This* tar installation defaults to:
Common options:
-C, --directory=DIR
change to directory DIR
-f, --file=ARCHIVE
use archive file or device ARCHIVE
-j, --bzip2
filter the archive through bzip2
-J, --xz
filter the archive through xz
-p, --preserve-permissions
extract information about file permissions (default for superuser)
-v, --verbose
verbosely list files processed
-z, --gzip
filter the archive through gzip
使用tar压缩文件
tar -zcvf 20200811.tar.gz ./dira/
该命令表示压缩当前文件夹下的文件夹test,压缩后缀名为test.tar.gz
如果不需要压缩成gz,只需要后缀为tar格式的,那么输入如下命令:
tar -cvf 20200811.tar ./dira/
使用tar解压文件
tar -xzvf aa.tar.gz
该命令表示把后缀为.tar.gz的文件解压到当前文件夹下。
如果压缩文件的后缀是.tar,没有gz,则使用命令:
tar -xvf aa.tar