• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

tar

zip multiple files into one zip

December 31, 2021

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

Filed Under: Linux Tagged With: directory, files, gzip, multiple, tar, zip

Tar List of Files

November 8, 2020

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

Filed Under: Linux Tagged With: archive, create, tar, verbose

Tar Commands

October 30, 2019

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

Filed Under: Linux Tagged With: create, directory, gzip, tar, untar

View contents of tar file

September 8, 2019

Here’s how to view the contents of a tar file without extracting the files.

tar -tvf file.tar

tar -tvf file.tar

Filed Under: Linux Tagged With: extracting, linux, tar, view, without

Add date to filenames

June 23, 2019

Here’s how to add date stamps to filenames. Uses epoch time.

tar cpzf mybackup-`date +%s`.gz /home/user

tar cpzf mybackup-`date +%s`.gz /home/user

Filed Under: Linux Tagged With: date, filenames, tar

  • Home
  • About
  • Archives

Copyright © 2023