O'Reilly logo

Linux Shell Scripting Cookbook by Sarath Lakshman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Archiving with tar

The tar command can be used to archive files. It was originally designed for storing data on tape archives (tar). It allows you to store multiple files and directories as a single file. It can retain all the file attributes, such as owner, permissions, and so on. The file created by the tar command is often referred to as a tarball.

Getting ready

The tar command comes by default with all UNIX like operating systems. It has a simple syntax and is a portable file format. Let's see how to do it.

tar has got a list of arguments: A, c, d, r, t, u, x, f, and v. Each of these letters can be used independently for different purposes corresponding to it.

How to do it...

To archive files with tar, use the following syntax:

$ tar -cf output.tar ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required