9951 explained code solutions for 126 technologies

cli-tarHow do I use the tar command in a Mac terminal?

The tar command is used to create an archive file of multiple files or directories in a Mac terminal. It can be used to compress, extract, and list the contents of an archive file.


To create an archive file called myarchive.tar from the directory mydir, use the following command:

tar -cvf myarchive.tar mydir

This command will create a myarchive.tar file in the current directory.

Code explanation

  • tar: the command
  • -cvf: flags for creating an archive file
  • myarchive.tar: the name of the archive file to create
  • mydir: the directory to archive

Helpful links

Edit this code on GitHub