Linux untar all tar gz

Содержание
  1. Untar Tar.gz – Linux Tar Command – HowTo: Extract Tar File
  2. Untar tar, tar.gz, tar.bx2 Files
  3. List the Contents of a tar, tar.gz, tar.bz2 Files
  4. Extract a Single File from a Tarball
  5. Extract a Single Directory from a Tarball
  6. How to extract multiple tar ball (*.tar.gz) files in directory on Linux or Unix
  7. The problem with multiple tar ball files on Linux/Unix
  8. Method #1: Untar and extract multiple tar ball files using bash for loop
  9. Method #2: Untar multiple tarballs using bash/sh/ksh pipes
  10. How To Extract a Tar Files To a Different Directory on a Linux/Unix-like Systems
  11. Understanding tar extracting CLI options
  12. Wrapping up
  13. 18 Tar Command Examples in Linux
  14. 1. Create tar Archive File in Linux
  15. 2. Create tar.gz Archive File in Linux
  16. 3. Create tar.bz2 Archive File in Linux
  17. 4. Untar tar Archive File in Linux
  18. 5. Uncompress tar.gz Archive File in Linux
  19. 6. Uncompress tar.bz2 Archive File in Linux
  20. 7. List Content of tar Archive File in Linux
  21. 8. List Content tar.gz Archive File in Linux
  22. 9. List Content tar.bz2 Archive File in Linux
  23. 10. Untar Single file from tar File in Linux
  24. 11. Untar Single file from tar.gz File in Linux
  25. 12. Untar Single file from tar.bz2 File in Linux
  26. 13. Untar Multiple files from tar, tar.gz, and tar.bz2 File
  27. 14. Extract Group of Files using Wildcard in Linux
  28. 15. Add Files or Directories to tar Archive File in Linux
  29. 16. Add Files or Directories to tar.gz and tar.bz2 Files
  30. 17. How To Verify tar, tar.gz, and tar.bz2 Archive File
  31. 18. Check the Size of the tar, tar.gz, and tar.bz2 Archive File
  32. Tar Usage and Options
  33. If You Appreciate What We Do Here On TecMint, You Should Consider:

Untar Tar.gz – Linux Tar Command – HowTo: Extract Tar File

Most of the Linux files that can be downloaded from the Internet are compressed with a tar , tar.gz and tar.bz2 compression formats and it is important to know how to extract such files.

The following article will help you to extract (unpack) and uncompress (untar) – tar , tar.gz and tar.bz2 files from the Linux command line.

You will learn how to list the contents of a tar archive without unpacking it and how to extract only a single file or a single directory.

File extension Description
tar Simple TAR archive without compression
tar.gz TAR archive compressed with GZIP
tar.bz2 TAR archive compressed with BZIP2

Cool Tip: No more wasted time! Download from the web and untar in one step from the Linux command line! Read more →

Untar tar, tar.gz, tar.bx2 Files

Extract a tar file:

Extract and uncompress a tar.gz file:

Extract and uncompress a tar.bz2 file:

Option Description
-x Extract files from an archive
-v Verbosely list files processed
-f Specify an archive or a tarball filename
-z Decompress the contents of the compressed archive created by gzip program ( tar.gz )
-j Decompress the contents of the compressed archive created by bzip2 program ( tar.bz2 )

List the Contents of a tar, tar.gz, tar.bz2 Files

For example, it goes without saying, that it is inadvisable to untar the whole large archive if you need for example to extract only a dingle file or a directory from it.

And of course this is possible with the Linux tar command, but firstly you need to check what is there inside the tarball without unpacking it.

List the contents of a tar file:

List the contents of a tar.gz file:

List the contents of a tar.bz2 file:

Option Description
-t List the contents of an archive
Читайте также:  Tablet driver gui linux

Cool Tip: There is no more need to remember all these -xvf , -xvzf , -xvif keys! This awesome bash function permits to extract any archive type with the single extract command! Read more →

Extract a Single File from a Tarball

Extract a file bar.txt , from an archive:

You can also specify a path to the file:

Extract a Single Directory from a Tarball

Extract a folder, called docs , from an archive:

Источник

How to extract multiple tar ball (*.tar.gz) files in directory on Linux or Unix

I have tried tar -xvf *.tar.gz command, but getting an error that read as:
tar (child): *.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
> tar: Child returned status 2
tar: Error is not recoverable: exiting now

How can I extract multiple *.tar.gz files in directory using Linux or Unix-shell prompt?

Tutorial details
Difficulty level Easy
Root privileges No
Requirements tar with Bash/KSH
Est. reading time 3 minutes

Linux or Unix-like system use the tar command to list, test, or extract files from a tar ball archive, commonly found on Unix-like systems including macOS, FreeBSD, OpenBSD, NetBSD and Linux distros. Let us see how to extract multiple tar ball files in a dirctory.

The problem with multiple tar ball files on Linux/Unix

Assuming that you have three files in the current directory as follows:

Let us verify it with the ls command $ ls
Here are my tar balls:

To untar all *.tar.gz file, enter:
$ tar xvf *.gz
# or #
$ tar -zxvf *.tar.gz
# or #
$ tar xvf «*.gz»
# trying *.gz files #
$ tar -zxvf ‘*.gz’
Sample outputs:

Fig.01: Extract multiple .tar.gz files

Method #1: Untar and extract multiple tar ball files using bash for loop

Verify it:
ls
Sample outputs:

Method #2: Untar multiple tarballs using bash/sh/ksh pipes

The syntax is:
cat *.tar.gz | tar zxvf — -i
cat *.tgz | tar zxvf — -i
cat *.tar.xz | tar Jxvf — -i
cat *.tar.bz2 | tar jxvf — -i
Sample outputs:

NOTE: The -i option force the tar command to ignore zeroed blocks in archive (EOF). This is needed if you are using method #2.

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

How To Extract a Tar Files To a Different Directory on a Linux/Unix-like Systems

Pass the -C dir option. For instance:

Understanding tar extracting CLI options

Where the tar command are as follows:

  • z : Filter the archive through gzip command
  • x : Extract option
  • v : Verbose output. In other words, show progress while extracting files
  • f : Filename to work on
  • i : See note above.
  • J : Filter for .xz file. See how to extract xz files for more info.
  • j : Filter for .bz2 file
  • : Read from pipe or stdin
  • C DIR_NAME : Cd in to the DIR_NAME before performing extract operations.

Wrapping up

We explained how to extract multiple tar ball files on Linux and Unix-like systems. See tar man page using the man command:
% man tar
% man bash
% help for

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

18 Tar Command Examples in Linux

The Linux “tar” stands for tape archive, which is used by a large number of Linux/Unix system administrators to deal with tape drives backup.

The tar command is used to rip a collection of files and directories into a highly compressed archive file commonly called tarball or tar, gzip and bzip in Linux.

The tar is the most widely used command to create compressed archive files and that can be moved easily from one disk to another disk or machine to machine.

Linux Tar Command Examples

In this article, we will be going to review and discuss various tar command examples including how to create archive files using (tar, tar.gz, and tar.bz2) compression, how to extract archive file, extract a single file, view content of the file, verify a file, add files or directories to the existing archive file, estimate the size of tar archive file, etc.

The main purpose of this guide is to provide various tar command examples that might be helpful for you to understand and become an expert in tar archive manipulation.

1. Create tar Archive File in Linux

The below example command will create a tar archive file tecmint-14-09-12.tar for a directory /home/tecmint in the current working directory. See the example command in action.

Let’s discuss each option used in the above command to create a tar archive file.

  1. c – Creates a new .tar archive file.
  2. v – Verbosely show the .tar file progress.
  3. f – File name type of the archive file.

2. Create tar.gz Archive File in Linux

To create a compressed gzip archive file we use the option as z. For example, the below command will create a compressed MyImages-14-09-12.tar.gz file for the directory /home/MyImages. (Note: tar.gz and tgz both are similar).

3. Create tar.bz2 Archive File in Linux

The bz2 feature compresses and creates an archive file less than the size of the gzip. The bz2 compression takes more time to compress and decompress files than gzip, which takes less time.

To create a highly compressed tar file we use the option j. The following example command will create a Phpfiles-org.tar.bz2 file for a directory /home/php. (Note: tar.bz2 and tbz is similar to tb2).

4. Untar tar Archive File in Linux

To untar or extract a tar file, just issue the following command using option x (extract). For example, the below command will untar the file public_html-14-09-12.tar in the present working directory.

If you want to untar in a different directory then use option as -C (specified directory).

5. Uncompress tar.gz Archive File in Linux

To Uncompress tar.gz archive file, just run the following command. If we would like to untar in different directories, just use option -C and the directory path, as shown in the above example.

6. Uncompress tar.bz2 Archive File in Linux

To Uncompress the highly compressed tar.bz2 file, just use the following command. The below example command will untar all the .flv files from the archive file.

7. List Content of tar Archive File in Linux

To list the contents of the tar archive file, just run the following command with option t (list content). The below command will list the content of the uploadprogress.tar file.

8. List Content tar.gz Archive File in Linux

Use the following command to list the content of the tar.gz file.

9. List Content tar.bz2 Archive File in Linux

To list the content of the tar.bz2 file, issue the following command.

10. Untar Single file from tar File in Linux

To extract a single file called cleanfiles.sh from cleanfiles.sh.tar use the following command.

11. Untar Single file from tar.gz File in Linux

To extract a single file tecmintbackup.xml from the tecmintbackup.tar.gz archive file, use the command as follows.

12. Untar Single file from tar.bz2 File in Linux

To extract a single file called index.php from the file Phpfiles-org.tar.bz2 use the following option.

13. Untar Multiple files from tar, tar.gz, and tar.bz2 File

To extract or untar multiple files from the tar, tar.gz, and tar.bz2 archive file. For example, the below command will extract “ file 1” “ file 2” from the archive files.

14. Extract Group of Files using Wildcard in Linux

To extract a group of files we use wildcard-based extracting. For example, to extract a group of all files whose pattern begins with .php from a tar, tar.gz, and tar.bz2 archive file.

15. Add Files or Directories to tar Archive File in Linux

To add files or directories to the existing tar archive files we use the option r (append). For example, we add file xyz.txt and directory php to the existing tecmint-14-09-12.tar archive file.

16. Add Files or Directories to tar.gz and tar.bz2 Files

The tar command doesn’t have an option to add files or directories to an existing compressed tar.gz and tar.bz2 archive file. If we do try will get the following error.

17. How To Verify tar, tar.gz, and tar.bz2 Archive File

To verify any tar or compressed archived file we use the option W (verify). To do this, just use the following examples of commands. (Note: You cannot do verification on a compressed ( *.tar.gz, *.tar.bz2 ) archive file).

18. Check the Size of the tar, tar.gz, and tar.bz2 Archive File

To check the size of any tar, tar.gz, and tar.bz2 archive file, use the following command. For example, the below command will display the size of the archive file in Kilobytes (KB).

Tar Usage and Options

  • c – create an archive file.
  • x – extract an archive file.
  • v – show the progress of the archive file.
  • f – filename of the archive file.
  • t – viewing the content of the archive file.
  • j – filter archive through bzip2.
  • z – filter archive through gzip.
  • r – append or update files or directories to the existing archive files.
  • W – Verify an archive file.
  • wildcards – Specify patterns in UNIX tar command.

That’s it for now, hope the above tar command examples are enough for you to learn, and for more information please use the man tar command.

If you are looking to split any large tar archive file into multiple parts or blocks, just go through this article:

If we’ve missed any examples please do share with us via the comment box and please don’t forget to share this article with your friends. This is the best way to say thanks…..

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.

Источник

Читайте также:  Mac pro как установить windows 10
Оцените статью