CIS 215 Introduction To Unix Frequently Asked Questions (FAQ)
Last Updated 1/7/05

1. Questions about using mail

1.1 While viewing mail, how do I convert a mail message
to become a UNIX file?

1.2 How do I copy a message or UNIX file to my home
computer file system?

1.3 How do I forward my mail to my other Internet
Mailing address?


2. Questions about printing

2.1 How do I print a message or UNIX file to my
home computer file system?

2.2 How do I print a message or UNIX file to my
School's (HCC) printer?


3. Questions about using vi

3.1 How did I get a .swp file?
How do I get rid of it?


4. Questions about using wildcards

4.1 When I type ls *[a-z]*, Why do I get matched filenames like Q5 and UIDVALUE as output?




1. Questions about using mail



1.1 While viewing mail, how do I convert a mail message to become a UNIX file?

    Once in the mail program and you get a & prompt, make the message
    current (e.g. p2) that you wish to save and then type:
    s unixfilename. i.e.:

$ mail                  # launches the mail program in management mode.
Mail version 8.1.1 6/6/93.  Type ? for help.
"/var/spool/mail/rkatz": 2 messages 1 unread
>U  1 rkatz@ned.highline.c  Fri Jun 19 16:49  13/406
    2 rkatz@ned.highline.c  Mon Jun 25 16:03  17/706
& p2                    # makes message 2 the current message and displays it
Message  2:
From unix215net-owner@ned.highline.edu  Mon Jun 25 16:03:13 2001
X-Authentication-Warning: ned.highline.edu: majordom set sender to owner-uni
x215net@ned.highline.edu using -f
Date: Mon, 25 Jun 2001 16:03:13 -0700
From: Faculty -- CIS 
To: unix215net@ned.highline.edu
Sender: owner-unix215net@ned.highline.edu
Precedence: bulk
Reply-To: unix215net_REPLY_TO@ned.highline.edu

hello

:q                      # quits displaying message and gives a mail prompt
& s test.62501          # saves the current message as test.62501 in
                        #    your current directory
& q                     # quits from mailx
$


1.2 How do I copy a message or UNIX file to my home computer file system?


    To copy a message to a home computer, first save it as a named UNIX file.
    (See 1.1).  There are two ways: (1) use your home computer's sftp program
    under PPP/Slip connection or
    (2) Use the copy and paste method.

    (1) If your home computer doesn't have a login/password sequence, Start
    from the home computer and ssh to ned.highline.edu. Launch sftp from
    ned.highline.edu to your home computer via:
    sftp -n 
    The sequence is shown below:
[rkatz@ned Grant] $ ftp -n 64.81.179.47
Connected to 64.81.179.47.
220 Macintosh Resident FTP server, ready
Remote system type is MACOS.
ftp> put 0.9unix215faq
200 This space intentionally left blank <   >
150 Opening connection
226 Transfer complete
4601 bytes sent in 0.00104 secs (4.3e+03 Kbytes/sec)
ftp> quit
221 Goodbye
[rkatz@ned Grant] $
    You may also launch your Home Computer's sftp client and access
ned.highline.edu
    The process will be the same, except the put command is replaced by get.

   (3) use the cat command to display the total contents of the file.
   (this requires your ssh window to have a scroll bar.)
   Use the mouse to select (highlight) the entire contents of the file.
   Select Copy on the menu at the ssh/terminal emulator window. Switch
   the active application to a word processor or launch it. With the word
   processor active, select Paste from its menu.  Then name the resulting
   new file as the same name.


1.3 How do I forward my mail to my other Internet Mailing address?


    mail recognizes a file called .forward when it is in your home directory.
    You can specify the E-mail address you want mail forwarded to and it
    will automatically show up there. You can create the .forward file by
    typing, for example (at a shell prompt $):
        echo arkay@speakeasy.org > .forward
    Be aware that you will not get any mail on the Linux incoming mailbox
    (including Exams and Assignments) when you invoke mail once forwarding
    is in effect and it is easy to forget that you have done this, since
    you only need to do it once. To undo this effect, just delete .forward


2. Questions about printing



2.1 How do I print a message or UNIX file to my home computer file system?


    Since The Linux Server doesn't know about your home printer, you will have
    to transfer the file from Linux to your home computer and print the
    resulting file from your home computer.  Some Terminal emulators have
    a "Print Selection" menu item. In that case, highlight the entire contents
    of the file (use the cat or more command to display it first), and then
    choose "Print Selection" from the terminal emulator menu.



2.2 How do I print a message or UNIX file to my School's (HCC) printer?


    If printing a message, save it as a file. Figure out the name of the
    nearest printer, somewhere in the room in Building 30. If stumped,
    type: $ lpstat -t
    This gives a list of all printers that are accepting print requests.
    Then type: $ lp -d r{roomnumber} printfilename(s)
         i.e.: $ lp -d r203 printfilename
    After a very short time, you should hear the printer activate and start
    printing your file.


3. Questions about vi (vim)



3.1 How did I get a .swp file? How do I get rid of it?


    On Linux, whenever you start a vi session and do not save or quit,
    but rather your session is interrupted, disconnected or aborted, a
    copy of your editing buffer is automatically saved to your current
    directory and is called: 
            .{filename}.swp
    This is a hidden file due to the initial '.' character prepended.
    (if this file existed, a new one named .{filename}.swo would be
    created instead, and so on.)
    When you next edit this file (assuming it is the latest version)
    you can run the recovery command:
       $ vi -r filename
    This will open the .swp file, with your recovered edits and let you
    continue. When you've saved or quit this new session, the file will
    automatically be deleted..
       If it is no longer represents the latest version, because you
    retyped it or have a new latest and greatest version, you can 
    deliberately remove it using the rm command:
       $ rm .{filename}.swp
    
    To see a list of all your recoverable files, type:
       $ vi -r

    If you have a recoverable file and you type:
       $ vi filename
    It will remind you that this file some recoverable text. If you
    want to access it, type: :q to get a shell prompt and then
       $ vi -r filename


4. Questions about wildcards 



4.1 When I type ls *[a-z]*, Why do I get matched filenames like Q5 and UIDVALUE as output?


    With most UNIX Systems, the character class [a-z] matches the lower case
    letters exclusively. In ned's Linux (Currently, Redhat Linux Version 
    3.2.2-5, Dec 18, 2003), the behavior is different, because the sort order 
    of ASCII characters (Collating Sequence) is different. In order to 
    accomodate internationalized character sets, with some letters being 
    accented, the sort order is all a's, then all b's, then all c's, and so on. 

    For English, which is unaccented, the sort order of [a-z] becomes
    aAbBcCdDeEfF...yYz
    The only letter missing from that character class is Z!

    What are the remedies? Instead of using [a-z] to match all lower 
    case letters, use either of: 
    (1) the alternate character class notation: [[:lower:]] 
    (2) explicitly specify the letters (ugh!): [abcdefghijklmnopqrstuvwxyz] 
    or
    (3) The Collating Sequence parameter: LC_COLLATE can be set to "C" to
    restore the collating sequence: abcdefg...xyzABCDEFG...XYZ
    via the entry: export LC_COLLATE=C  in user's .bash_profile
    or the system's /etc/profile to cover all users.




For any questions, corrections, additions, contact:
Robert Katz: rkatz@ned.highline.edu
Last Update January 7, 2005