All commands tested on Mac OS Monterey / Jan 05, 2022

How to create a tar archive of a directory

Create a tar archive called my-directory.tar of a directory my-directory/ in the current working directory.

You can use this short tar command.

              
                  tar -cvf my-directory.tar my-directory/
              
          

Or this more verbose tar command.

              
                  tar --create --verbose --file my-directory.tar my-directory/
              
          

Options explained

  1. -c or --create tells tar to create a new archive
  2. v or --verbosetells tar to produce verbose output
  3. f or --filetells tar that the next parameter will be the tar file to create, extract, append to, list, etc.

More commands for creating tar archives