How to tar archive a directory in one location and output to another location

Last modified date

Comments: 0



You have a directory in a location that you want to create a compressed tar archive of and output to another directory.


The following command will compress and create a tar.gz archive of a directory in a particular location and output to another location.

tar czvf ../myFolder/archive.tar.gz -C ../myProject/projectFiles .

-c will compress the files

-z use gzip

-v will print out logs during the operation

-f allows you to specify the filename

-C tells tar to change directory

. tells tar to archive all of the files in the directory.


Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.