最近接到一个需求,要从tar中提取一些文件,顺便总结了一下tar在windows下的用法。
1. 查看帮助
D:\test>tar --help
Usage: tar [OPTION...] [FILE]...
GNU `tar' saves many files together into a single tape or disk archive, and can
restore individual files from the archive.
2. 对指定类型的文件进行打包
D:\test> tar cvf test.tar *.txt
3. 对所有的文件打包
D:\test> tar cvf test.tar *
4. 显示tar包中文件内容
D:\test>tar tf test.tar
5. 提取tar包中的所有文件
D:\test>tar xvf test.tar
6. 提取tar包中指定的文件
D:\test>tar xvf test.tar 文件名
7. 提取tar包中的文件到指定的路径
D:\tar xvf test.tar -C D:/test/aaa
8. 提取tar包中指定的文件到指定的路径
tar xvf test.tar -C d:/test/aaa 文件名
9. 排除tar包中的指定类型文件
tar xvf test.tar --exclude=*.txt