9951 explained code solutions for 126 technologies


cli-tarHow do I create a tar file in Unix?


Creating a tar file in Unix is a simple process. The following command will create a tar file from all the files and directories in the current directory:

tar -cvf my_files.tar *

This command will create a tar file called my_files.tar containing all the files and directories in the current directory.

The parts of the command are:

  • tar - the command to create a tar file
  • -cvf - the flags to create a tar file, verbosely list the files added, and name the tar file
  • my_files.tar - the name of the tar file to create
  • * - the argument to add all files and directories in the current directory

For more information, see the GNU tar manual.

Edit this code on GitHub