Win10 cmd如何试用tar命令压缩和解压文件夹

环境:

Win10 专业版

Microsoft Windows [版本 10.0.19041.208]

问题描述:

Win10 cmd如何试用tar命令压缩和解压文件夹

C:\Users\Administrator>tar --help
tar(bsdtar): manipulate archive files
First option must be a mode specifier:
  -c Create  -r Add/Replace  -t List  -u Update  -x Extract
Common Options:
  -b #  Use # 512-byte records per I/O block
  -f <filename>  Location of archive (default \\.\tape0)
  -v    Verbose
  -w    Interactive
Create: tar -c [options] [<file> | <dir> | @<archive> | -C <dir> ]
  <file>, <dir>  add these items to archive
  -z, -j, -J, --lzma  Compress archive with gzip/bzip2/xz/lzma
  --format {
    
    ustar|pax|cpio|shar}  Select archive format
  --exclude <pattern>  Skip files that match pattern
  -C <dir>  Change to <dir> before processing remaining files
  @<archive>  Add entries from <archive> to output
List: tar -t [options] [<patterns>]
  <patterns>  If specified, list only entries that match
Extract: tar -x [options] [<patterns>]
  <patterns>  If specified, extract only entries that match
  -k    Keep (don't overwrite) existing files
  -m    Don't restore modification times
  -O    Write entries to stdout, don't restore to disk
  -p    Restore permissions (including ACLs, owner, file flags)
bsdtar 3.3.2 - libarchive 3.3.2 zlib/1.2.5.f-ipp
命令参数解释
t	显示档案文件列表内容(已压缩的文件)
x	解压档案文件
c	生成档案文件,创建打包文件
f	指定档案文件名称,f必须放在命令参数最后

解决方案:

1.压缩文件

cmd命令

tar -cf xxx.tar.gz ./xxx

打包123.txt文件

tar -cf 123.tar.gz ./123.txt

在这里插入图片描述打包345文件夹

tar -cf 345.tar.gz ./345

在这里插入图片描述

2.解压文件

cmd命令

tar -xf xxx.tar.gz

解压 345.tar.gz文件

tar -xf 345.tar.gz

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42672685/article/details/132900030