How to zip multiple files into one zip file.
Using zip.
zip test.zip *.txt |
Using tar.
tar cvzf test.tar.gz *.txt |
Untar in current directory or specify another directory.
tar xvzf test.tar.gz . tar xvzf test.tar.gz -C /path/to/dir |
cloud engineer
How to zip multiple files into one zip file.
Using zip.
zip test.zip *.txt |
zip test.zip *.txt
Using tar.
tar cvzf test.tar.gz *.txt |
tar cvzf test.tar.gz *.txt
Untar in current directory or specify another directory.
tar xvzf test.tar.gz . tar xvzf test.tar.gz -C /path/to/dir |
tar xvzf test.tar.gz . tar xvzf test.tar.gz -C /path/to/dir
Here’s another way of creating a tar ball from a list of files.
tar -cvf backup.tar.gz a.txt b.txt c.txt d.txt e.txt |
tar -cvf backup.tar.gz a.txt b.txt c.txt d.txt e.txt
Here’s how to view files in a tarball.
tar -tvf backup.tar.gz |
tar -tvf backup.tar.gz
Here are two important tar commands on how to create and extract a tar.gz file.
Create a tar gzip file called “project.tar.gz” of a directory called “foo.”
tar -cvzf project.tar.gz foo |
tar -cvzf project.tar.gz foo
Untar the “project.tar.gz” file to a directory called bar.
tar -xvzf project.tar.gz bar |
tar -xvzf project.tar.gz bar