% ls README btree.c btree.h main.c % tar cvf hw10.tar main.c btree.c btree.h README % ls README btree.c btree.h hw10.tar main.c
In this example, the btree.h, btree.c, main.c and README files are combined into a single tarfile named hw10.tar
WARNING: be sure to include the destination tarfile name argument to tar (in this example it is the hw10.tar argument), otherwise tar will overwrite the contents of one of the source file arguments with the tarfile. In fact, before you create a tarfile, it is a good idea to create copies of these files in another directory. One way to do this is to create a subdirectory "handin" and copy the files there before taring:
% mkdir handin
% cp *.[ch] handin/.
Next, create a tarfile. If you forget the destination file in the tar command
and overwrite a source file with garbage, you have a copy in handin of the
original file.
% mkdir handin % cp *.[ch] handin/. % cp README handin/. % tar cvf hw10.tar handinIf you forget to list the tar file target (hw10.tar) in the tar command, tar will exit with an error message.
% tar xvf hw10.tar handin/ handin/README handin/btree.c handin/btree.h handin/main.c
% tar tf hw10.tar handin/ handin/README handin/btree.c handin/btree.h handin/main.cFor more information look at the man page for tar: % man tar