| MATLAB Function Reference | ![]() |
tar(tarfilename,files)
tar(tarfilename,files,rootdir)
entrynames = tar(...)
tar(tarfilename,files) creates a tar file with the name tarfilename from the list of files and directories specified in files. Relative paths are stored in the tar file, but absolute paths are not. Directories recursively include all of their content.
tarfilename is a string specifying the name of the tar file. The .tar extension is appended to tarfilename if omitted. The tarfilename extension can end in .tgz or .gz. In this case, tarfilename is gzipped.
files is a string or cell array of strings containing the list of files or directories 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 directory or with an absolute path. Directories must be specified relative to the current directory or with absolute paths. On UNIX®[1] systems, directories can also start with ~/ or ~username/, which expands to the current user's home directory or the specified user's home directory, respectively. The wildcard character * can be used when specifying files or directories, except when relying on the MATLAB path to resolve a file name or partial path name.
tar(tarfilename,files,rootdir) allows the path for files to be specified relative to rootdir rather than the current directory.
entrynames = tar(...) returns a string cell array of the relative path entry names contained in tarfilename.
Tar all files in the current directory to the file backup.tgz:
tar('backup.tgz','.');
gzip, gunzip, untar, unzip, zip
[1] UNIX is a registered trademark of The Open Group in the United States and other countries.
![]() | tanh | tempdir | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |