untar
Extracts the files of a tar archive.
Category: Programming > Files and Folders
Syntax
untar(tarfilename)
Extracts into the current folder.
untar(tarfilename, outputfolder)
Extracts into outputfolder, creating it if needed.
filenames = untar(___)
Also returns the names of the extracted files.
Description
The directory structure stored in the archive is recreated below the output folder. Existing files with the same names are overwritten. untar is the inverse of tar.
Input arguments
tarfilename- Archive name, with extension
.tar,.tgzor.tar.gz. outputfolder- Destination folder.
Output arguments
filenames- Cell array with the names of the extracted files.
Example
Archiving and restoring
mkdir data
writelines('1', 'data/a.txt');
tar('bundle.tar', 'data');
files = untar('bundle.tar', 'restored')
isfile('restored/data/a.txt')
Output
files = 1×1 cell
{'restored\data\a.txt'}
ans = logical
1