환경:
Win10 프로페셔널 에디션
마이크로소프트 윈도우 [버전 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