Linux Tutorial
We can use tar command to compress the files or directories.
GNU 'tar' is used to save many files together into a single tape or disk archive, and also can restore individual files from the archive.
tar [OPTION...] [FILE]...
-c, --create: create a new archive
-f, --file=ARCHIVE: use archive file or device ARCHIVE
Below command is used to compress the test1 directory into archive file.
$ tar -cf test1.tar test1
$ ls test1 test1.tar
Below command is used to compress the test1 directory into archive file.
$ tar -cf test2.tar.xz test2
$ ls test1 test1.tar test2 test2.tar.xz
Lets delete test1 and test2 directories,
$ rm -rf test1 test2
Now extract the test1.tar and test2.tar.xz archive files,
we can use same tar command with option -x,
$ tar -xf test1.tar $tar -xf test2.tar.xz
Lets see the extract directories in current directory,
$ ls test1 test2 test1.tar test2.tar.xz
Linux Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us | Report website issues in Github | Facebook page | Google+ page