Create tarball in from a different directory

Let say you are in a  destination directory but the source are in a different directory.

To create a tarball, just issue this command below,


$> PWD
 /Users/user/Desktop/
$> tar -cvzf mytarball.gz -C ~/different/source/base-directory TheDirectoryToTarBall



What it means is that, it'll create the tarball mytarball.gz into present working directory which is /Users/user/Desktop which the directory going to tar is TheDirectoryToTarBall with its location is in ~/different/source/base-directory, i.e. ~/different/source/base-directory/TheDirectoryToTarBall. Take note that after the path "...base-directory" is a space before the directory named "TheDirectoryToTarBall".

If you want to tar a file, just replace the position of your file to the position where "TheDirectoryToTarBall" is placed.

Hope that helps.

Comments

Popular posts from this blog

What is Disk Contention?

Converting sectors into MB - Useful in understanding the sectors in iostat in Linux