9951 explained code solutions for 126 technologies


cli-tarHow do I use tar command line parameters?


The tar command is used to create, modify, and extract archives from various types of files. It is commonly used to compress files for storage or transport.

The basic syntax of the tar command is:

tar [options] [archive file] [files or directories]

The following are some of the commonly used parameters for the tar command:

  • -c: Creates an archive
  • -x: Extracts files from an archive
  • -t: Lists the contents of an archive
  • -v: Displays progress information
  • -f: Specifies the name and path of the archive file

For example, to create an archive named myarchive.tar from the files file1.txt and file2.txt, the command would be:

tar -cf myarchive.tar file1.txt file2.txt

To extract the contents of the archive, the command would be:

tar -xf myarchive.tar

For more information about the tar command, see the following links:

Edit this code on GitHub