9951 explained code solutions for 126 technologies

cli-tarHow do I use the Unix tar syntax?

The tar command is a Unix utility that is used to archive multiple files into a single file. The syntax for using the tar command is as follows:

tar -[options] [filename.tar] [files]


  • -options: Options that control how the archive is created.
  • filename.tar: The name of the archive file to be created.
  • files: The files to be archived.

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

tar -cvf myarchive.tar file1.txt file2.txt

In this example, the options used are:

  • -c: Create an archive.
  • -v: Verbose output.
  • -f: Specify the name of the archive file.

The output of this command would be:


For more information, see the GNU tar manual.

Edit this code on GitHub