In order to create a tar.gz file using Terminal you can make use of the tar command with the following options,
tar -czf tar-gz-file-name.tar.gz [files to tar.gz]
Option | Description |
---|---|
-c | To create a new archive for the secified files, can also use --create |
-z | To compress the files as archive with gzip, can also use gizip --gunzip |
-f | Read the archive from or write the archive to the specified file, can also use --file |
Exampl 1: tar.gz specfied files seperated by space
tar -czf tarfile.tar.gz file1.txt file2.txt
Example 2: tar.gz all files in current directory
tar -czf tarfile.tar.gz .*
Example 3: tar.gz all txt extenstion files in current directory
tar -czf tarfile.tar.gz *.txt
Example 4: tar.gz all files that start with file and has extension txt
tar -czf tarfile.tar.gz file*.txt
More Posts related to Linux,
- Command to know the Available Memory on Linux System
- How to install curl on Alpine Linux
- How to backup a file in Linux/Unix
- Install Java Runtime Environment (Oracle or open JRE) on Ubuntu
- What is the Default Admin user and Password for Jenkins
- How to tar.gz a directory or folder Command
- Copy entire directory using Terminal Command [Linux, Mac, Bash]
- Fix: bash: ipconfig: command not found on Linux
- Command to check Last Login or Reboot History of Users and TTYs
- Linux: Create a New User and Password and Login Example
- ls command to list only directories
- bash: cls: command not found
- How to exit from nano command
- Installing and using unzip Command to unzip a zip file using Terminal
- What does apt-get update command does?
- ls command: sort files by name alphabetically A-Z or Z-A [Linux/Unix/macOS/Bash]
- How to remove or uninstall Java from Ubuntu using apt-get
- scp: ssh: connect to host xxxx port 22: Connection refused Error
- Sort ls command by last modified date and time
- Create Nested Directories using mkdir Command
- How to Exit a File in Terminal (Bash/Zsh)
- Command to know the installed Debian version?
- How to connect to SSH port other than default 22
- How to save a file in Nano Editor and Exit
- Install OpenSSL on Linux/Ubuntu
More Posts:
- How to crop a screenshot on Mac/Macbook - MacOS
- How to stop and start a docker container - Docker
- Minecraft Fix: Error: UNKNOWN code: Deep Ocean - Something went wrong in the login process - Windows
- Python Program To Calculate Simple Interest (SimpleInterest.py) - Python
- How to Calculate the SHA Hash Value of a File in Java - Java
- Fix - Java: invalid source release: IntelliJ IDE - Java
- bash: command not found error [macOS Terminal Linux, Unix or Windows] - MacOS
- Quick steps to install Nginx on Ubuntu Linux - Ubuntu