cli-tarHow do I create and extract a Unix tar file?
Creating and extracting a Unix tar file is a simple process. To create a tar file, use the command tar -cvf <name>.tar <files and/or directories>, where <name> is the desired name of the tar file and <files and/or directories> is a list of files and/or directories to be included in the tar.
For example, to create a tar file named my_tar.tar that includes the file my_file.txt and the directory my_dir, use the command:
tar -cvf my_tar.tar my_file.txt my_dir
To extract the contents of a tar file, use the command tar -xvf <name>.tar, where <name> is the name of the tar file.
For example, to extract the contents of my_tar.tar, use the command:
tar -xvf my_tar.tar
The parts of the command are as follows:
tar: The command to create or extract a tar file.-c: The flag to create a tar file.-v: The flag to display the progress of the tar operation.-f: The flag to specify the name of the tar file.
Helpful links
More of Cli Tar
- How do I use the command line to tar and zip files?
- How can I use tar commands to zip a file?
- How do I use the shell to tar and zip files?
- How do I use the command line to tar and zip a file?
- How do I use the Unix tar zip command?
- How do I create a tar.zip file in Unix?
- How do I use the command line to tar and zip a file?
- How do I use the command line to tar and zip a file?
- How do I use the command line to tar and distribute files?
- How do I use gzip, tar, and zip to compress files?
See more codes...