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

Image cCreate an archive. ...

Get Ubuntu Unleashed 2014 Edition: Covering 13.10 and 14.04,Ninth 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.