LinuxLinux tar, gz and bz2

Linux tar, gz and bz2

  • t: List the contents of an archive
  • v: Verbosely list files processed (display detailed information)
  • z: Filter the archive through gzip so that we can open compressed (decompress) .gz tar file
  • j: Filter archive through bzip2, use to decompress .bz2 files.
  • f: File. Use the tar file argument as the name of the tar file
  • x: Extract or restore
  • c: Create

tar

tar -tvf file.tar : list the contents of the tar file 
tar -xvwf myfile.tar : extract all files from the tar 
tar xvf test.tar testfile1.bz2 : extract only the file called testfile1.bz2 from a tar archive
tar -cvwf txtfiles.tar *.txt : create a tar of all .txt files, name the tar file txtfiles.tar and put it in the current dir

bz2 ( bunzip2 )

tar -jtvf file.tar.bz2 : list the contents of the tar.bz2 file
tar -xvjpf filename.tar.bz2 : unzip a file compressed with .tar.bz2 
bzip2 filename.txt : compress a file with bunzip2 
bunzip2 filename.bz2 : unzip a file compressed only with bz2

gzip ( gunzip )

tar -ztvf file.tar.gz : list the contents of the tar.gz file
gzip filename.txt : compress a file using gunzip
gunzip filename.txt.gz : uncompress a file using gunzip

Categories: Linux

Comments

No Comments Yet. Be the first?

Post a comment

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