Extract group of files from archive.tar using –wildcards
View Files
tar tvf archive.tar
View the archive.tar files
Add New Files/Directories
tar rvf archive.tar new_file
tar rvf archive.tar new_dir/
Exclude certain files
tar -cvf archive.tar --exclude='a.php'
--exclude='*.bak' dir_name
Archive.tar.gz
Create Archive
tar cvzf archive.tar.gz dir_name/
Creating a tar gzipped archive, filter the archive through gzip
Extract Files
tar xvfz archive.tar.gz
Extracting all files from archive.tar.gz
tar xvfz archive.tar /path/to/file
Extract a single file from archive.tar
tar xvfz archive.tar /path/to/dir/
Extract a single directory from archive.tar
tar xvfz archive.tar --wildcards '*.php'
Extract group of files from archive.tar using –wildcards
View Files
tar tvfz archive.tar
View the archive.tar files
Add New Files/Directories
tar rvfz archive.tar new_file
tar rvfz archive.tar new_dir/
Exclude certain files
tar -cvfz archive.tar.gz --exclude='a.php'
--exclude='*.bak' dir_name
Archive.tar.bz2
Create Archive
tar cvfj archive.tar.bz2 dir_name/
Creating a bzipped tar archive, filter the archive through bzip2
Extract Files
tar xvfj archive.tar.bz2
Extracting all files from archive.tar.bz2
tar xvfj archive.tar.gz
Extracting all files from archive.tar.gz
tar xvfj archive.tar /path/to/file
Extract a single file from archive.tar
tar xvfj archive.tar /path/to/dir/
Extract a single directory from archive.tar
tar xvfj archive.tar --wildcards '*.php'
Extract group of files from archive.tar using –wildcards
View Files
tar tvf archive.tar View the archive.tar files
Add New Files/Directories
tar rvfj archive.tar new_file
tar rvfj archive.tar new_dir/
Exclude certain files
tar -cvfj archive.tar.bz2 --exclude='a.php'
--exclude='*.bak' dir_name
Options Description
c – create a new archive
v – verbosely list files which are processed.
f – following is the archive file name
z – filter the archive through gzip
j – filter the archive through bzip2
x – extract files from archive
r - add new files or directories
--exclude='file_name' - execute the files while creating tarball