Languages
[Edit]
EN

Bash - extract *.tar.gz file in Linux

5 points
Created by:
Marcin
2453

In this short article we would like to show how to extract *.tar.gz file using Linux Command Line.

Quick soution:

tar -xzvf /path/to/file.tar.gz

Output:

reports/2020-01/log.1.txt
reports/2020-01/log.2.txt
reports/2020-01/log.3.txt
reports/2020-01/log.4.txt
reports/2020-01/users/log.1.txt
reports/2020-01/users/log.2.txt
reports/2020-01/users/log.3.txt

Where:

  • -x means archive extracting,
  • -z means gz decompression,
  • -v means pringin in console progress as paths to extracted files,
  • -f means /path/to/file.tar.gz ahould be attached.

Extracting only specific paths

By adding next parameter we are able to specify the path, that we want to extract only.

tar -xzvf /path/to/file.tar.gz reports/2020-01/users

Output:

reports/2020-01/users/log.1.txt
reports/2020-01/users/log.2.txt
reports/2020-01/users/log.3.txt

See also

  1. Bash - compress files with tar command in Linux
Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.