ragnarokkrr
6/6/2016 - 5:52 PM

From http://www.thegeekstuff.com/2010/04/unix-tar-command-examples/

$ tar cvfW file_name.tar dir/

$ tar tvfW file_name.tar

$ tar dfz file_name.tgz


$ tar dfj file_name.tar.bz2

$ tar rvf archive_name.tar newfile

$ tar rvf archive_name.tar newdir/

$ tar xvf archive_file.tar --wildcards '*.pl'

# –wildcards *.pl – files with pl extension

$ tar xvf archive_file.tar /path/to/dir/

$ tar xvf archive_file.tar /path/to/dir1/ /path/to/dir2/

$ tar xvfz archive_file.tar.gz /path/to/dir/

$ tar xvfj archive_file.tar.bz2 /path/to/dir/

$ tar xvf archive_file.tar /path/to/file

$ tar xvfz archive_file.tar.gz /path/to/file

$ tar xvfj archive_file.tar.bz2 /path/to/file

# http://www.thegeekstuff.com/2009/04/linux-less-command-open-view-different-files-less-is-more/

$ set | grep less
LESSOPEN='|/usr/bin/lesspipe.sh %s'

$ eval "($lesspipe)"

$ cat ~/.bashrc
eval "($lesspipe)"

# File Type 1: How to open a pdf file?


$ less Linux-101-Hacks.pdf


# File Type 2: How to open a word document file?

$ less pdb.doc


# File Type 3: How to open a jpg, jpeg, png file?
$ less testfile.jpeg

# File Type 4: How to open an archived file (i.e *.tar) ?

$ less autocorrect.tar

# File Type 5: How to open an archived, compressed file in gzip format (i.e *.tar.gz format) ?
$ less XML-Parser-2.36.tar.gz

# File Type 6: How to open an archived and compressed file in zip format (i.e *.zip format)?
$ less bash-support.zip

# File Type 7: How to open a compressed file gzip & bzip2.


# File Type 8: How to open an ISO file?

$ less knoppix_5.1.1.iso


# File Type 9: How to open a deb file?

$ less lshw_02.08.01-1_i386.deb

# File Type 10: How to open a rpm file?


$ less openssl-devel-0.9.7a-43.16.i386.rpm



$ tar tvf archive_name.tar

$ tar tvfz archive_name.tar.gz

$ tar tvfj archive_name.tar.bz2

$ tar xvf archive_name.tar

# x – extract files from archive

$ tar xvfz archive_name.tar.gz

$ tar xvfj archive_name.tar.bz2
$ tar -cf - /directory/to/archive/ | wc -c
20480

$ tar -czf - /directory/to/archive/ | wc -c
508

$ tar -cjf - /directory/to/archive/ | wc -c
428
$ tar cvf archive_name.tar dirname/


# c – create a new archive
# v – verbosely list files which are processed.
# f – following is the archive file name

$ tar cvzf archive_name.tar.gz dirname/

# z – filter the archive through gzip

$ tar cvfj archive_name.tar.bz2 dirname/

# j – filter the archive through bzip2