tar

Compress files into tar file

Syntax

tar(tarfilename,files)
tar(tarfilename,files,rootfolder)
entrynames = tar(...)

Description

tar(tarfilename,files) creates a tar file named tarfilename from the list of files and folders specified in files. Folders recursively include all of their content. If files includes relative paths, the tar file also contains relative paths. The tar file does not include absolute paths.

tar(tarfilename,files,rootfolder) specifies the path for files relative to rootfolder rather than the current folder. Relative paths in the tar file reflect the relative paths in files, and do not include path information from rootfolder.

entrynames = tar(...) returns a string cell array of the names of the files contained in tarfilename. If files includes relative paths, entrynames also contains relative paths.

Input Arguments

tarfilename

String specifying the name of the tar file. If tarfilename has no extension, MATLAB® appends the .tar extension. The tarfilename extension can end in .tgz or .gz. In this case, tarfilename is gzipped.

files

String or cell array of strings containing the list of files or folders included in tarfilename.

Individual files that are on the MATLAB path can be specified as partial path names. Otherwise an individual file can be specified relative to the current folder or with an absolute path.

Folders must be specified relative to the current folder or with absolute paths. On UNIX® systems, folders can also start with ~/ or ~username/, which expands to the current user's home folder or the specified user's home folder, respectively. The wildcard character * can be used when specifying files or folders, except when relying on the MATLAB path to resolve a file name or partial path name.

rootfolder

String specifying the path for files.

Examples

Tar all files in the current folder to the file backup.tgz.

tar('backup.tgz','.');

More About

expand all

Tips

tar cannot compress folders larger than 2 GB.

See Also

| | | |

Was this topic helpful?