Compress Tar Gz Mac

broken image


Tar is a command line tool used to create and manipulate archive files in Linux and Unix systems. Tar command creates .tar archive file and then compress using gzip or bzip2.

  1. Compress Tar Gz Macro
  2. Windows Tar Gz
  3. How To Tar Gz
  4. Compress Tar Gz

It's suitable for both Windows and Mac users. TAR.GZ is great for Unix users and by extension, Mac users. Many MacOS versions allow you to double-click a TAR.GZ file to extract it. However, if you are a Window's user, you will need additional software to extract a TAR.GZ file. How to Compress Files in the ACC.

If you want to gzip a file or a directory, you can do it by running a simple command using Terminal. Go to Spotlight Search and type Terminal and Open it, Now browse to the location where the file or folder is presently using the cd command. If the file is situated on the desktop: cd. Note: gzip is in-built in Mac. It is a combination of.tar and.gz i.e. It is a tar archive file that has been compressed with gzip; It is mostly common in Unix/Linux; Command to both archive and compress files in terminal (MAC). Common compressions applied to a.tar file are Gzip, bzip2, and xz. That's why you rarely see just a.tar file and more commonly encounter.tar.gz or.tgz files. On Linux, BSD, Illumos, and even Mac OS, the tar command is already installed for you.

You can create a single archived compressed file using one command to get .tar.gz file or .tar.bz2 files. Tar command can be also used to extract archived files.

Let's see tar command in action through some practical examples.

1) Create .tar archive file

To create an uncompressed tar (.tar) , use -c option with tar command as following:

Where '/path/to/foo.tar' is the location of resulting tar file, and '/path/to/foo' is the location of the file or directory to use as input.

Example

You can use an absolute path instead of relative as shown in the example.

2) Create a .gz archive with tar

The command syntax to create a .gz archive with tar is:

Where '/path/to/foo.tgz' is the destination compressed file, and '/path/to/foo/' is source directory or file to be compressed.

3) Create a .bz2 archive

The option -j is used to work with .bz2 archives.

4) Create a .gz archive and exclude

We use --exclude tar option to exclude a specific extension or list of file extensions. The syntax is similar to below:

5) Use tar with no absolute path on compress

When using tar to compress files and you provide an absolute path, a compressed file will have a full path in its metadata, So when you extract the content, it will be in directories similar to the absolute path that was passed. To avoid this, add a . at the end of the command.

6) Tar all files starting specific letter

Create a tar archive of everything in the current directory starting with an 'i'.

Create tar gz file

7) Append new file to existing tar archive

Append a file or add a new file to existing tar archive.

The above command will append an anaconda-ks.cfg file in the backup.tar archive

8) Adding two archive files with concatenate option

The above command adds the content of the fullbackup.tar to backup.tar archive.

9) Extract .tar archive file

To extract an uncompressed archive which often has an extension .tar, the command syntax is:

Where /path/to/foo.tar is the absolute/relative path to the location of a tar file. E.g

10) Extract a .gz archive

To extract a .gz archive, we use the command syntax:

Where '/path/to/foo.tgz' is the absolute or relative path to the compressed file.

11) Extract a .bz2 archive

Compress Tar Gz Macro

The command syntax to extract a .bz2 archive is Mac red rock lipstick swatches.

Note that you can pass a .tgz file as long as it was compressed with a -j option. Tar will auto-detect the format and uncompress it.

12) Extract a .tar in specified Directory

To extract a tar archive to a specific directory, use -C option to provide destination directory.

13) Extract file from tar archive

Mac os high sierra cannot be installed on macintosh hd. The following command extracts the 'anaconda-ks.cfg' file in the 'backup.tar' archive.

14) List contents of .gz archive

Suppose you only want to view the contents of a .tgz file without extracting them, you'll use the command syntax:

Just replace '/path/to/foo.tgz' with correct path of your .tgz file

15) List content of .bz2 archive file

If you would like to just view the content of .bz2 archive without extracting, use the command:

16) Preserve symbolic links using tar command

Use tar -cvhf to preserve my symbolic links when generating a tar archive (Use the option 'h' for that).

Conclusion

Windows Tar Gz

Its hard to remember all options of tar command. Below is a list of commonly used tar options.

- j : Used to filter archive through bzip2.
- v : Run the command in verbose mode to show the progress of archive file.
- f : Specify archive filename.
- W : Used to verify an archive file.
- z : Filter an archive through gzip tool.
- t : This is used to view the content of archive file.
-c : Create a new archive containing the specified items.
-r : Used for appending or updating existing archive with files or directories
-t : List contents of an archive on stdout.
-u : Like -r, but new entries are added only if they have a modification date newer than the corresponding entry in the archive.
-x : Extract archive file to disk.

For all tar operations, the utility exits with a 0 on success, and >0 if an error occurs. It is important to understand this if you're using tar with a script.

How To Tar Gz

I hope you enjoyed reading this tutorial on tar command. Please leave your suggestions in the below comment section.

Compress Tar Gz

Read Also:





broken image