网站如何宣传,wordpress自定义评论头像,男女做视频网站,网站域名怎么查文件压缩及解压缩命令
tar — 打包和压缩 tar 是一个用于打包文件的工具#xff0c;常常用来将多个文件或目录打包成一个单独的文件。它本身不进行压缩#xff0c;但可以与压缩工具#xff08;如 gzip 或 bzip2#xff09;一起使用。 用法#xff1a; 打包文件#xff0…文件压缩及解压缩命令
tar — 打包和压缩 tar 是一个用于打包文件的工具常常用来将多个文件或目录打包成一个单独的文件。它本身不进行压缩但可以与压缩工具如 gzip 或 bzip2一起使用。 用法 打包文件不压缩tar -cf archive.tar /path/to/directory_or_files 解释 c创建一个新的归档文件。 f指定归档文件的名称。 archive.tar创建的归档文件名称。 打包并使用 gzip 压缩tar -czf archive.tar.gz /path/to/directory_or_files 解释 z表示使用 gzip 压缩归档文件。 tar.gz打包并压缩后的文件扩展名。 打包并使用 bzip2 压缩tar -cjf archive.tar.bz2 /path/to/directory_or_files 解释 j表示使用 bzip2 压缩归档文件。 tar.bz2打包并压缩后的文件扩展名。 解包和解压文件tar -xzf archive.tar.gz 解释 x表示解压缩。 z表示使用 gzip 解压缩。 f指定归档文件名。
实例
[rootiZ2vch0mnibclcpxzrbu5rZ ~]# tar -czf test/backup.tar.gz test/src/
[rootiZ2vch0mnibclcpxzrbu5rZ test]# ls
backup.tar.gz file1.txt file2.txt output.txt src xaa xab[rootiZ2vch0mnibclcpxzrbu5rZ ~]# tar -xzf test/backup.tar.gz -C test
[rootiZ2vch0mnibclcpxzrbu5rZ ~]# ls test/
backup.tar.gz file1.txt file2.txt output.txt src test xaa xabgzip — 压缩工具 gzip 是一种压缩工具主要用于压缩单个文件。它常与 tar 配合使用来压缩整个目录。 用法
压缩文件gzip filename 解释 filename待压缩的文件。 压缩后文件名为 filename.gz原文件会被替换。压缩文件并保留原文件gzip -k filename 解释 -k保留原文件不会删除。 通过运行 gzip --help 查看 gzip 支持的选项确认是否支持 -k 选项。如果 -k 不在支持的选项中那么说明您的 gzip 版本不支持该选项。 使用 -c 选项代替 -k gzip -c file2.txt file2.txt.gz解压 .gz 文件gunzip filename.gz或者gzip -d filename.gz
示例
[rootiZ2vch0mnibclcpxzrbu5rZ test]# ls
file1.txt file2.txt file3.txt output.txt src test xaa xab
[rootiZ2vch0mnibclcpxzrbu5rZ test]# gzip file1.txt
[rootiZ2vch0mnibclcpxzrbu5rZ test]# ls
file1.txt.gz file2.txt file3.txt output.txt src test xaa xab
[rootiZ2vch0mnibclcpxzrbu5rZ test]# gzip -c file2.txt file2.txt.gz
[rootiZ2vch0mnibclcpxzrbu5rZ test]# ls
file1.txt.gz file2.txt file2.txt.gz file3.txt output.txt src test xaa xab
[rootiZ2vch0mnibclcpxzrbu5rZ test]# gunzip file2.txt.gz
gzip: file2.txt already exists; do you wish to overwrite (y or n)? y
[rootiZ2vch0mnibclcpxzrbu5rZ test]# ls
file1.txt.gz file2.txt file3.txt output.txt src test xaa xabunzip — 解压 .zip 文件 unzip 是一个用于解压 .zip 文件的工具适用于将 .zip 格式的压缩文件解压到指定目录。 用法
解压文件unzip archive.zip 解释 archive.zip待解压的 .zip 文件。解压到指定目录unzip archive.zip -d /path/to/directory 解释 -d指定解压到的目标目录。查看 .zip 文件的内容unzip -l archive.zip
zip — 压缩工具 zip 是一种压缩工具用于将多个文件或目录压缩成 .zip 格式的压缩文件。zip 格式广泛应用于 Windows 系统中。 用法
压缩文件或目录zip archive.zip file1 file2 directory 解释 archive.zip压缩包的输出文件。 file1, file2待压缩的文件。 directory待压缩的目录。递归压缩目录中的所有文件zip -r archive.zip directory 解释 -r递归压缩目录中的所有文件和子目录。查看 .zip 文件内容zipinfo archive.zip解压 .zip 文件unzip archive.zip
实例
[rootiZ2vch0mnibclcpxzrbu5rZ test]# ls
file1.txt.gz file2.txt file3.txt output.txt src test xaa xab
[rootiZ2vch0mnibclcpxzrbu5rZ test]# zip archive.zip file2.txt file3.txt adding: file2.txt (stored 0%)adding: file3.txt (stored 0%)
[rootiZ2vch0mnibclcpxzrbu5rZ test]# ls
archive.zip file1.txt.gz file2.txt file3.txt output.txt src test xaa xab[rootiZ2vch0mnibclcpxzrbu5rZ test]# ls
archive.zip file1.txt.gz file2.txt file3.txt output.txt src test xaa xab
[rootiZ2vch0mnibclcpxzrbu5rZ test]# cd ..
[rootiZ2vch0mnibclcpxzrbu5rZ ~]# ls
archive.zip test
[rootiZ2vch0mnibclcpxzrbu5rZ ~]# unzip archive.zip -d test/test1
Archive: archive.zipcreating: test/test1/test/src/creating: test/test1/test/src/cfg/
[rootiZ2vch0mnibclcpxzrbu5rZ ~]# cd test
[rootiZ2vch0mnibclcpxzrbu5rZ test]# ls
archive.zip file1.txt.gz file2.txt file3.txt output.txt src test test1 xaa xab