美文网首页
gunzip 和 unzip 解压文件到指定的目录

gunzip 和 unzip 解压文件到指定的目录

作者: mrknowledge | 来源:发表于2021-05-11 17:53 被阅读0次

    gzip 命令:

    # gzip test.txt

    它会将文件压缩为文件 test.txt.gz,原来的文件则没有了,解压缩也一样

    # gunzip test.txt.gz

    它会将文件解压缩为文件 test.txt,原来的文件则没有了,为了保留原有的文件,我们可以加上 -c 选项并利用 linux 的重定向

    # gzip -c test.txt > /root/test.gz

    这样不但可以将原有的文件保留,而且可以将压缩包放到任何目录中,解压缩也一样

    # gunzip -c /root/test.gz > ./test.txt

    zip 命令:

    # zip test.zip test.txt

    它会将 test.txt 文件压缩为 test.zip ,当然也可以指定压缩包的目录,例如 /root/test.zip

    # unzip test.zip

    它会默认将文件解压到当前目录,如果要解压到指定目录,可以加上 -d 选项

    # unzip test.zip -d /root/

    相关文章

      网友评论

          本文标题:gunzip 和 unzip 解压文件到指定的目录

          本文链接:https://www.haomeiwen.com/subject/ikdndltx.html