Copying Files Using tar

One choice for copying files into another location is to use the tar command; you just create a tar file that is piped to tar to be uncompressed in the new location. To accomplish this, first change to the source directory. Then the entire command resembles this:

matthew@seymour:~$ tar -cvf files | (cd target_directory ; tar -xpf)

In this command, files are the filenames you want to include; use * to include the entire current directory.

Here is how this command works: You have already changed to the source directory and executed tar with the cvf arguments that tell tar to

c—Create an archive.

v—Verbose; lists the files processed so you can see that it is working.

f—The filename of the archive will be what follows. ...

Get Ubuntu Unleashed 2013 Edition: Covering 12.10 and 13.04, Eighth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.