_ _ ___ | |__ __ _ _______ | |_ / _ \| '_ \ / _` |_ / _ \| __| | (_) | | | | (_| |/ / (_) | |_ \___/|_| |_|\__,_/___\___/ \__|
| ohazot | docs | links | dev | conf | txt |
| es | en |
| mdoc file |
| search |
tar —
archive tool: usage
SYNOPSIS
tar -zvcf TAR_FILE
DIRECTORYtar -zvcf TAR_FILE
DIRECTORY/*tar -zvxd TAR_FILEOPTIONS
| -c | : compress |
| -x | : extract |
| -v | : verbose |
| -f TAR_FILE | : use specified TAR_FILE |
| -z | : use gzip compression |
| -j | : use bzip2 compression |
| -t | : list archive contents |
| -C DIR | : cd to directory |
tar -zvxf tar_fileextracting specific files
- Filename(s) can be specified to extract only specified file(s).
- The full path inside the tar file needs to be specified.
$ tar -ztf tar_file d1/file1 d2/file2 $ tar -zxf tar_file d1/file1
Using -C
- Compress the contents of dir_to_compress located in parent_directory into
dir.tar.gz.
$ pwd cur_directory $ ls parent_directory dir_to_compress $ tar -C parent_directory -zcf dir.tar.gz dir_to_compress $ ls parent_directory dir.tar.gz
- Extract the contents of TAR_FILE into EXTRACT_DIR.
$ tar -C EXTRACT_DIR -zxf TAR_FILE
SEE ALSO
- OpenBSD manpages: tar(1)