gunzip

Decompresses files compressed with gzip.

Category: Programming > Files and Folders

Syntax

gunzip(filename)

Extracts filename (a .gz file) next to the original.

gunzip(filename, outputfolder)

Extracts into outputfolder.

files = gunzip(___)

Also returns the names of the extracted files.

Description

A .gz file holds one compressed file. gunzip removes the .gz suffix to name the result, and writes it to the folder of the archive unless an output folder is given. The original .gz file is left in place.

gzip does the reverse.

Input arguments

filename
Name of the .gz file, or a pattern, or a cell array of names.
outputfolder
Destination folder; created if missing.

Output arguments

files
Cell array with the names of the files that were written.

Example

Round trip through gzip

writelines(["one"; "two"], 'log.txt');
gzip('log.txt');
mkdir plain
gunzip('log.txt.gz', 'plain');
disp(fileread('plain/log.txt'))
Output
one
two

See also

gzip unzip untar zip