Tar files are package files that store multiple files inside itself.
You can think of them like Zip files, if you are aware of those. This
way, if a lab requires multiple files to be submitted, throw all of the
required files into a Tar and submit that one file instead.
How to package files up via Tar (In a nutshell)
Let's say I completed Lab 1, Part 1 (Prog1a, Prog1b, Prog1c) and I
want to submit it. The lab writeup states to only submit Prog1b.cpp
and Prog1c.cpp. So...
UNIX> ls -la
drwxr-xr-x. 2 cnguyen graduate 89 Jan 15 19:24 .
drwxr-xr-x. 5 cnguyen graduate 48 Jan 12 05:20 ..
-rw-------. 1 cnguyen graduate 120 Jan 12 05:22 Prog1a.cpp
-rw-------. 1 cnguyen graduate 526 Jan 13 01:52 Prog1b.cpp
-rw-------. 1 cnguyen graduate 685 Jan 13 01:55 Prog1c.cpp
-rw-------. 1 cnguyen graduate 1056 Jan 13 01:58 Prog1d.cpp
-rwxr-xr-x. 1 cnguyen graduate 6352 Jan 12 05:21 prog1_ints
From the files above,
are what we want. Let's tar them into a single file called
UNIX> tar -cvf lab1.tar Prog1b.cpp Prog1c.cpp
This will create
, including all files
specified after "lab1.tar" specified in the command. So it'll
Because someone will be curious, the arguments "cvf" stand for:
"c" means "create". It's telling tar we are making a
tar file ("x" is for "extracting").
"v" means "verbose". It will tell you what files are
going into the tar file.
"f" means "file". The argument that comes after this
one is the filename of the tar that will be written to
MAKE SURE THE NAME OF THE TAR COMES AFTER -cvf!
Otherwise, you'll accidentally overwrite a file. Tar does not prompt
you to overwrite files. It just does it. If I did
tar -cvf Prog1b.cpp Prog1c.cpp,
then it'll obliterate
Prog1b.cpp and make it
into a tar file that only has
Prog1c.cpp in it. We
cannot help you if you accidentally overwrite your source code (IT
can though. They back up directories daily).
Check if your Tar file is valid (In a nutshell)
Method 1: You can use "tar -tf FILE" to check:
UNIX> tar -tf lab1.tar
"t", for some reason, means "list
" in tar. It lists all
files packaged into the tar file.
If you're on Windows, just download 7zip and open the Tar
file with it.
If you're on a Mac, it has tar support embedded right in the OS.
You can just open the file.
If you're on Linux, it depends on what software packages
you have. But if you're on Linux, I'll assume you know what
Make sure you don't include a directory
Whenever you submit, please make sure you don't put the files in
a directory and tar the directory unless specified.
tar -tf to show what I mean. This isn't
a valid submission:
UNIX> tar -tf lab1.tar
The reason why is because, upon extraction, it will create
as a directory and then put files in that directory. You can tell by
the "lab/" before each file. It would extract to this: