tar is an Archiving Utility that is commonly used on Linux and Unix systems. We will be compressing it with GZip which tar calls for high-compression ability. Let's delve right into the command line and get our hands dirty, shall we? Oh, but with two of them. tar -cvzf tar-example.tar.gz file1.txt *.c images/ tar -xvzf tar-example.tar.gz There's a few tasty tar lines. First, we'll go through the one on the top and its variables. The argument -c will create a new .tar.gz file (c for create). The -v argument will show you all the files that it has processed (v for verbose). -z will do the compression using gzip, a compression utility with a lot of power (z for zip). And the final argument, -f, means to use an archive file (f for file). Also, you can use -j instead of -z for compression using bzip2, another compression utility. If you use bzip2, the file will have the ending .tar.bz2 Now, we'll get to the other parts of the tar command. tar-example.tar.gz is the file you are going to archive the files into. file1.txt will add the file named file1.txt to the archive. *.c will add all files in this directory that have a .c extension to the archive. images/ will add everything in the images folder into a folder named images/ inside of the tar.gz file. Let's look at a file tree for clarity, ok? ~/files `images/ `image1.png `image2.png `file1.txt `main.c `player.c The Directory ~/files `tar-example.tar.gz `images/ `image1.png `image2.png `file1.txt `main.c `player.c `images/ `image1.png `image2.png `file1.txt `main.c `player.c The Folder After using Tar You see? It takes everything exactly how you saw it and compresses it into your .tar.gz file! It even keeps the directories in their current state instead of mixing them together! How Awesome! Now, I guess we should discuss the other tar line that I gave you above, eh? The second tar line will extract the .tar.gz file into the current directory. The only variable that changes is -c to -x (create to extract).When you run that command, it will extract all of the files in the .tar.gz file into the directory you are located in. Let's look at another file tree for clarity. ~/files `tar-example.tar.gz Before Extraction ~/files `images/ `image1.png `image2.png `file1.txt `main.c `player.c `tar-example.tar.gz Well there we go. Your lesson in tar is done! How did you like it? If you're not getting the grasp of it, then try it out! It will make a lot more sense once you start using it on your own. Well, now you can finally distribute your game. But, is this series really done? Read on in the next page to find out more and see my closing statements.
|
|