Tar
Jump to navigation
Jump to search
Basic Commands
Create archive with gzip
tar cvzf archive_name.tar.gz /path/to/dir/
Untar to different directory
tar -zxvf tarball.tar.gz -C /path/to/dir/
Search a tar archive for a file
tar tf archive.tar.gz | grep foo
Extract a specific file or dir
Use relative paths for within the file, helpful to tar -tf first
tar -zxvf /path/to/backup.tar.gz -C /destination/dir backup/path/to/fileordir
Test a tarball to see if it's valid
tar -tf tarball.tar.gz >/dev/null
Docs & Links
http://www.thegeekstuff.com/2010/04/unix-tar-command-examples/