Archiving and Compressing Files with Tar on macOS Tahoe
tar (Tape Archive) is the standard command-line utility for bundling multiple files into a single archive file. On macOS Tahoe, it is commonly used for backups, transferring groups of files, and compressing data.
Creating an Archive
To bundle a folder into a single .tar file (without compression):
tar -cvf archive_name.tar /path/to/folder
-c: Create a new archive.-v: Verbose (show the progress).-f: Filename of the archive.
Creating a Compressed Archive
To bundle and compress files using Gzip (resulting in a .tar.gz or .tgz file), add the -z flag. This is the most common usage.
tar -czvf archive_name.tar.gz /path/to/folder
Extracting an Archive
To unpack an archive:
tar -xvf archive_name.tar.gz
-x: Extract.
By default, this extracts files into the current directory. To extract to a specific folder, use -C:
tar -xvf archive_name.tar.gz -C /path/to/destination
Listing Archive Contents
To see what is inside an archive without extracting it:
tar -tvf archive_name.tar.gz
-t: List contents.
Common Flags Summary
| Flag | Meaning |
|---|---|
-c |
Create a new archive. |
-x |
Extract an archive. |
-f |
File (allows you to specify the filename). |
-v |
Verbose (prints filenames as they are processed). |
-z |
Compress with Gzip (.tar.gz). |
-t |
List contents. |
For more on general terminal usage, refer to Getting Started with macOS Tahoe.