
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,
- [Fix] Linux - bash: useradd: command not found
- Calculate days between dates using dateutils ddiff command
- pwd Command - Print Working Directory
- Rename a directory using Linux/Unix command
- How to go to the End of File in Nano Editor
- How to tar.gz a directory or folder Command
- How to remove/delete a directory in Linux/macOs
- How to Display content of a file in Terminal Screen?
- ls command sort by file size [Linix/UNIX/macOS/bash]
- How to Copy Entire Directory to another Directory in Linux
- 3 ways to clear screen on Linux Terminal
- Command to check Last Login or Reboot History of Users and TTYs
- How to check uptime of Linux/Unix/macOS system/server using console command?
- How to backup a file in Linux/Unix
- Command to know the installed Debian version?
- Check SSH/OpenSSH version Command
- 3 Commands to stop Nginx Server
- Linux: Create a New User and Password and Login Example
- How to install npm on Ubuntu
- How to List All Users in Linux
- How to Get the List of Shells on Linux
- Fix - ssh-copy-id no identities found error
- Installing and using unzip Command to unzip a zip file using Terminal
- scp: ssh: connect to host xxxx port 22: Connection refused Error
- zsh hello world example
More Posts:
- PHP Base64 encoding decoding a variable - PHP
- Plug-in com.android.ide.eclipse.adt was unable to lead class Error - Android
- [fix] Java NullPointerException ComparableTimSort countRunAndMakeAscending when sorting a List - Java
- Trace using cURL Command Example - cURL
- Replace delimiter with new line in Notepad++ - NotepadPlusPlus
- Calculate discount amount python code - Python
- The default interactive shell is now zsh. [macOS] - MacOS
- Take Screenshot on Mac OS X (Keyboard Shortcuts) - Mac-OS-X