Home > Operation and Maintenance > Linux Operation and Maintenance > gunzip and unzip decompress files to the specified directory

gunzip and unzip decompress files to the specified directory

巴扎黑
Release: 2017-06-23 14:16:16
Original
4442 people have browsed it

Commonly used compression commands in Linux include gzip and zip. The endings of the two compressed packages are different: the zip compressed file is *.zip, and the gzip compressed file is *.gz
Correspondingly The decompression commands are gunzip and unzip

gzip command:
# gzip test.txt
It will compress the file into the file test.txt.gz, and the original file will be gone. The same goes for compression

# gunzip test.txt.gz
It will decompress the file into the file test.txt, and the original file will be gone. In order to retain the original file, we can add - c option and use linux redirection

# gzip -c test.txt > /root/test.gz
Not only can the original files be retained, but the compressed package can be placed anywhere directory, decompression is the same

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


zip command:
# zip test.zip test.txt
It will compress the test.txt file into test.zip. Of course, you can also specify the directory of the compressed package, such as /root/test.zip

# unzip test.zip
It The file will be decompressed to the current directory by default. If you want to decompress to the specified directory, you can add the -d option

# unzip test.zip -d /root/

The above is the detailed content of gunzip and unzip decompress files to the specified directory. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template