| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
tar(tarfilename,files)
tar(tarfilename,files,rootfolder)
entrynames =
tar(...)
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.
tarfilename is a 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 is a 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.
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.
Tar all files in the current folder to the file backup.tgz.
tar('backup.tgz','.');
gzip, gunzip, untar, unzip, zip
![]() | tanh | tempdir | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |