next up previous
Next: Getting on to the Up: unix_guide Previous: LATEX, PostScript, PDF, Printing

E-Mails, Sending and Receiving Files, Tar, Gzip

Summary of this section

Now that you have created a wonderful program or a beautiful document, maybe you'd like to show it to somebody or maybe somebody already sent you their handy work. So to read e-mails, type

HAL9000> pine
That'll get you into pine. I can't explain all the intricacies of pine here, but it's quite intuitive. The cursor control usually works as one expects it to work, and there is a menu bar at the bottom showing what the available commands are and what they are for. To summarize:

To send a file directly to other user without going through an e-mail program, you can do

HAL9000> mail [email protected] < foo.txt
But this works only if foo.txt is an ascii file. To send non-ascii files, use attachment as explained below.

Now suppose you want to send files foo_1.txt through foo_20.txt. You can send it one by one. However, that's time consuming, prone to errors, and quite frankly, the other person will get horrified to receive 20 separate mail messages for 20 separate files because he/she has to edit out all the mail headers one by one, put them in the right directories, etc., the horrors. So, be smart and considerate and use tar.

The Unix utility tar comes in quite handy when you want to collect a number of files, even directories, in one file. The word tar originally meant ``tape archive" but these days, it is widely used to just collect a lot of files in one convenient file. To do so

HAL9000> tar cvf all_foo.tar file_1 file_2 foo_*.txt
Here cvf means ``create (c) a file (f) showing what you are doing verbatim (v)''. As before, * in Unix means ``anything" or the ``wild card". This will create a file named all_foo.tar which contains file_1, file_2 and foo_1.txt, foo_2.txt, ..., foo_a.txt, foo_b.txt, .... So now send all_foo.tar to the person at the other end.

A tar'ed file is a binary file. And as such, it loses bits and pieces if you send it through e-mail as a body text. Send it using `attachment'. When you compose a message, you will see `Attachment' in the header. Just provide the path to the file you want to attach.

A word of caution. If you make a mistake and omit the tar file to be made (all_foo.tar in the example above), then the first file listed will be taken to be the tar file to be made (file_1 in the example above). You can guess what will happen then: The content of that first file is destroyed. So be careful.

Now, if you happened to be the person at the receiving end of a tar file, do

HAL9000> tar xvf all_foo.tar
Here xvf means ``extract (x) from a file (f), showing what you are doing verbatim (v)". This will now create all the foo_*.tex files in the directory all_foo.tar is in.

If you received a tar.gz file, you can first gunzip it and do the above or you can simply do

HAL9000> tar zxvf all_foo.tar.gz
Note the additional z.

If the files you are sending out are really big ones, then you might wish to compress it first. The original Unix compress command is, funnily enough, compress. which produces a .Z file. These days, the ``GNU zip", that is gzip or the newer bzip2 are more commonly used since they are more efficient. To gzip or bzip2,

HAL9000> gzip all_foo.tar
or
HAL9000> bzip2 all_foo.tar
This produces a file all_foo.tar.gz (all_foo.tar.bz2) where the extension .gz (.bz2) means it is gzip'ed (bzip2'ed). To decompress,
HAL9000> gunzip all_foo.tar.gz
or
HAL9000> bunzip2 all_foo.tar.bz2
Incidentally, gunzip will also unzip the Zipped files with .Z extension.


next up previous
Next: Getting on to the Up: unix_guide Previous: LATEX, PostScript, PDF, Printing
Sangyong Jeon 2007-09-18