Docstoc

UNIX

Document Sample
UNIX Powered By Docstoc
					;




     UNIX       .          W


    A Quick Guide for unix Newbies
                                          Edition 2.4E
                                     September 4, 1995
This booklet was prepared with LTEX2" using the CJK package and
                                 A
TTF2PK for PK font generation from Chinese True Type Font.
The LTEX2" macro package CJK was written by Werner Lemberg
     A
(a7621gac@awiuni11.bitnet).
The TTF2PK program was written and prepared by                           r                       $   and
A       $                                        .




Copyright c 1995
    h       .   &            |   &       ]   P                               h           I   /

                             C                           v       J               6   D   3   N

                    C                J               T       |       8               (Free Software
Foundation)             GPL (General Public License)                         q   A
;




    For Victoria
                            `                                                                   y       !                                       \                                                                                                                                                                   6               &

                    W               X       |           b                                   &                                           \local guide"                                                                   W                            (Edition 1.0)                                                              x                        !

            !               @                                                                   (                               y       `                                                               /                                           \ "     +                           P                   /                       K    j   E

                            (               1                               W                                       3           @                           /               /       I                                           ^                                   E                   2                                                    9

W           m                                                       9                                   -                                                   /               $                           E                       W           b   X       Q                                           1                               X

            E                                       T               T                           |       Q                       ?       9                                   b                                                   F                   \           \                                                           `            3   B           4

                                            |       C                               B               l                                                                                               P           |           \2.4 "                          2                       3                           `                        1994    O           8
`



                O                       X       X                       #                                               B                   *                                   |       C       ;           <                   3           h           l                               =               ;                            '   k   y   J

j   n               P                       9                       B                           (                                               A                                   3                                                                                                   "           &

    0       ^               .       /                                                                   3                       P                                           R                                                                                       p                           3                   b       F                    &

                    \Edition 2.4E"                                              G                               b           n                                   I       5                   B                   t                                   3           K           S                                               TANet                        b

                            ]               B           9                   b       m                           \                               |                                                   T                                       2.4                                             6   a                       M           -    I               h

b   n           X Window                                    I           5   3           |                                                                                           t



        9                                                   \UNIX                                   .                       "       :               h               x                                   )           3                                                                                               .                UNIX
T           E               .           UNIX                                    b           X       Q                                                   |               #                                       h           T           D           \ftp"                                           A

    \ftp"                                                   >

;

                                            ;       ;   ftp://moers2.edu.tw/chinese-pub/documents/UNIX-Guide
                            ;       ;       ;       ;   ftp://ftp.csie.nctu.edu.tw/Documents/UNIX-Guide
                            ;       ;       ;       ;   ftp://ftp.cis.nctu.edu.tw/Documents/UNIX-Guide
                                |               9               h                                                                                                               J                                                                       X           b           E               h

C                                           A                       b                       m                               K                           #



                h       3       _                                       b                                   #       T                                       X           U               !                               T           l                       3           h                       1                       ;                    A   h

)                   1       J       h               /               ^       b                   0               \                       A                   s                                       |                                           2   ]                       K                       *       (Email)
                                    *       O               : JS@v0sun11.ccl.itri.org.tw                                                                                                        t                                                       &




                                                        Happy UNIXing !!




                                                                                                                                                                                                                                                                                                                            y            z

                                                                                                                                                                                                                                                                                                                                    1995     O       8   `




                                                                                                                                                                                    i
ii
Contents

1       s       G                                                                                                               1
    1.1 Login                       : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :        1
    1.2 File System - A Short Trip                              : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :    7
    1.3 Logout                           : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :    11

2   +       UNIX                                                                                                                13
    2.1             -           :    :        : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :   13
    2.2                              .         : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :    15
    2.3     j       n   J                : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :    25
    2.4             #                    : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :    27
    2.5     1               : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :             40
    2.6     "       .                    : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :    42
    2.7 1752                O       9     `    : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :    44

3 UNIX                                                                                                                          47
    3.1             ?                         : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :   47
    3.2                     : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :             47
    3.3                 '       v        : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :    48
    3.4 Richard M. Stallman                               : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :   49
    3.5     _                       : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :       51
    3.6                                        : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :    52
                                                                          iii
Contents                                                                                                                                     Contents

4           $       C Shell                                                                                                                          55
    4.1                                       .cshrc                         : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :      55
    4.2                               (Prede ned Variables) :                              : : : : : : : : : : : : : : : : : : : : : : : : : : : :    56
    4.3             (       (alias)           a                (history)        : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :       61
                4.3.1 Alias :                             : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :               61
                4.3.2 History                                  : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :            62
                4.3.3                 M   A                      : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :            62
    4.4             (                 (Environment Variables)                                : : : : : : : : : : : : : : : : : : : : : : : : : : :    71

5   :   :               @    j                                                                                                                       77
    5.1 One Example - .cshrc                                                 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :      77
    5.2 One Example - .login                                                 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :      82
    5.3 One Example - .logout                                                 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :       86
    5.4         b                         t       ?                          : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :      86

6 Tour of Tools                                                                                                                                      91
    6.1 V-eye                        : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :                            91
                6.1.1                 T                    "    8       : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :         91
                6.1.2 vi                              P    b                  : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :       92
                6.1.3                                               : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :           92
                6.1.4 ed                      P                     vi       : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :      96
    6.2 sed                      Regular Expression                               : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :       98
                6.2.1 Find and Replace                                          : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :       98
                6.2.2            <    g                         ^ : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :               99
                6.2.3            <    g                         $:      : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :         99
                6.2.4            <    g                    C    -               : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :      100
                6.2.5            9                C             <   g             ...] :   : : : : : : : : : : : : : : : : : : : : : : : : : : : :   100
                6.2.6            <    g           T        9        C    -           : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :     101
                                                                                               iv
Contents                                                                                                                   Contents

          6.2.7          &               M                       : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :   103
    6.3   n   y        sed                                 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :   106
    6.4       +        grep                   : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :          107
          6.4.1 grep                           4       : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :     108
    6.5       +        cut                    : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :          109
    6.6   5   -                   paste       : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :          111
    6.7       b        tr :       : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :              112

7   .     C Shell Script                                                                                                           115
    7.1                                Shell Script            : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :   115
    7.2           Shell Script                 j       (     : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :   119

8 X Window System                                                                                                                  123
    8.1 Open the Window                                : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :     123
    8.2 X Resources                          : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :         125
    8.3 A Little More :                       : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :          127

9                                                                                                                                  129
    9.1   S   +               b    (               P       : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :   129
    9.2                           : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :              132
    9.3   e        1              : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :              135
    9.4 Finale               : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :                 135




                                                                              v
                                                                                                                                                                                                                                                                                       : : : we             came in ?




Chapter 1

            s                            G




                    UNIX                                          b                       V           (account)                                                   6           '                                                                                                             @                                       \
                (        "(username)                                      |       C                    \ "(password)  D                                                                               D                       1                                       j   n            1                                        1

    6               6                                                 UNIX                                9                                                                       t                                           b           &       9                                !

                         N                                    K                   b               username                                                    N                               K           b           (           C                                       password                              ?




1.1 Login
b               V                ^                                                                login                       9                               +                                   login               b       n                   M                   C    8       n    j       n

UNIX            A        I                                                            A           .               H           H       3                                           A                                             \ "                                                                                         UNIX
    5                                    v            {       X       b                                               P           K                                                   9                   F                   DOS                  b                                    !                                   UNIX
        j       n   (            ^       b       %            /                               v       j       n                               |                       256                         C           -           b                                       UNIX                                  #           t       9       14
    C   -           j    n       (                            9                                                   9                                                   %                   (           C                       %                   (       C                            b        %

        MS-DOS                                            j       (                       b           8           C           -                       j       (           t           9                           b       3                   C       -



        login                                                                                                             r                   A



%
T

ccsun2 /1 >


9                   r       \                                         r "(System Prompt)                                                                  h           `                           B           3       UNIX                                                         ?            @               1

B   3                   Shell                                         Shell     \ "                               $                               H                                                                                                                            N                            K               Shell
    .                    \



            9                c               ?             PC                                 DOS             -                   9           &                                       PC DOS             \>"                          `                       3                                                                 E

        |       9        1                             Shell                                  Q                               UNIX                        9           \                "           \ "            T           1                                   P                                                     X       |

        |                        !                   Shell                    H                                                                               |                         /bin/csh C Shell                                                                                            |       /bin/sh
    Bourne Shell                                      T                                                                           tcsh bash                                                               #                                           |                                                 Shell                   9

F     DOS                            !                    3           UNIX                                                    |           C                                                                       Shell                                   3                                     r

                                                                                          '                   Shell                                               1                   A                                                           Sun                                                                   C Shell
                                                                                                                                                          1
1.1. Login                                                                                                                                                                                                                                                                                    Chapter 1.                           s        G




                           login                                                                          b                       \ "     $



                      A                                                                                                       Shell                                                                               |           :                   :           9                       j       n               /etc/passwd (
    \more /etc/passwd"                                        )                                           W           9


.....
.....
john:ACrBqjTb8JmxQ:149:200:John Cooley:/home/users/john:/bin/csh
cpy:,xcrggtKWJTUA:172:200:C. P. Y:/home/users/cpy:/bin/tcsh
math:po.isgMVOPEw:110:200:Guess Who?:/home/users/math:/bin/sh
smith:ouzoi1EiDuJuk:129:200:Bob Smith:/home/users/smith:/bin/csh
student1:ou..41EiDuJuk:159:300:Talking Head:/home/users/student1:/bin/csh
.....
.....



9     j   n   N                 L               user \ "                              |                                       5                                   r                                       L                               user login name(username)
password login                                \ " (Home directory)                                                                                        |       C               login                                                          \ "
                  |       \ "       5                         4                   5                   1                       y




1. username                                   4                                               login                   `                           username                                                                                        1                                                           #

                                            (         C                                                   -                                               f           A                       3           .           l                           K                               .       r                   (           ^   %

                                                          ]           -                                                               t           &                       b           %                                                                                                                       ?       B                 %

                                        ...                       J                       9               4                                       P                                                                       A                                                                           username                     k

                                            @         3                   K                       E                   R                                                                                               .               T                                                           ?       (   C           3             1

                                        "   4                     (                   full name                                                               f                       @           j




2. password                                   4                                                                   D                       B                                                   _           D                                           Z           C                                                   |            '    ^   b

                                              |           9                   B                                                       C               -                                   W                       3           login                       `       X               key in                          password
                            D                         |                                                                   ?                                                                           6           B                                                   H                                       D                    #

                            username      password                                                                                                    T                                                                               C                       z           Z               (                     1234567 An-
                            nie James               password                          K                               ?                                                                                               #                           |           1                           ?                   password
                                     a5g2s7ts s$ bb%d!&|
                                                      A                                                                                                                                                       Q                   G                                                                   B                       3             g

                            login                 `           K                                       B                                                                                       t           D                                                                                       F               b

                                  \password 1     "                                                       B




3. user id                                    4                                                       \           5               J           C           r       "                                                   username                                                                         (                      9         r   D

                                                                                                                          3                       X                                                                                           ^           b                                                           (       C        (user-
                            name)                                 ^       b                               \               5           J           C           r           "(USER ID)                                                                                                                   @              3           UNIX
                                                                                                                                                                          9   user id                                                                                 |                   \id"         9                           :

                            user id                           9                   1                       group id
4. group id                                   4                                               X                               N                           _       r                                                   N                   .                       K                   3               y

                            3           UNIX                              N                                                                                           5           v                                   X                           $                                       N               9               $        K    b

                            }                 P                       _       r                                               group id                                                    9                       .                                                   5       v                                   3

                            |           ?     ]       -                                                   j               n                       f           A           1                       !                                           group                                                       |                        j    n

                                        `                                 group                                               \                       9                       j           n                       N                                                                               y           K                   group
                                                                                                                                  !           `                       y           ?                                       group                                                                   .               |                O

                                        .                         !       `




                                                      |        \groups"                                       9                                                           :                                               y                                               group                        9

                                        X   3                 group                                                                                                                                                           ^       b                                   %               ^       b                           .




                                                                                                                                                              2
Chapter 1.                             s               G                                                                                                                                                                                                                                                1.1. Login

                                                                        ^       b   Q                   5           v                   `
                                                                                                                                                            1                           |       :                           /etc/group                                  9           j                                               b

                                                   F                    3                       passwd                              j                                   b           4                                           \           $               (                   :       D       :   $           _       r       :
                                                   $            W               1       W         2 ..."
                                                           9            j       n                                                                       '                               X       |       1                                                               X                                           T

                                                                $




5. full name                                               "    4                                               |                               ?                       4                                       K                                                                           (               |       ]       -

                                                               username                                                                                 n                                               3                                                               `                   *                       |

                                                           *                                               username                                                                                             ?                       Q                               |                                                           (

                                                   )            (       C                       Albert Einstein Bill Clinton                                                                                                                K               |




6. home directory                                                   0       4                   L                               X                   \                           "           9       ?       f                               V               (           '           t                       r

                                                           5    J       C       r                                                               B                               2                                       9                                                                   5           g                   2

                                                                                                            login                                   UNIX                                                                            .               \   H           H       "       9                       y                       2

                                                   8            9                                                                                                                                       5       g



                                                           9            \ "                             F                   3           UNIX                                                                .                UNIX                                                           X               9               9

                                                                                                        1                   !                                           /                       b               y            !          `       3                                   v                   N                   K

                                                   b       !                                                                                                                                    j                       N                       K                       5                   s

                                                           \ "                  N                                           3                                   \ "                                         X       k                                   |                   W                                       X       |

                                                                6       j       n                                                               K                       w       3                                                       b           E                   J

                                                   .            n               T   .                                               }                                                           Q       A                               W                                           |

                                                                                            f                                                                                                                                                                                               :           :   j       n

                                                                        %                                       b                                       y                                               ?               =                       K                                                       =                           K




7. shell                                                        4                   L                                               3                       login                                               X                                                                                           L

                                                                X                       Shell                   (                                                                                                                           9               4                       |                                               3

                                                                                r   `




     |               +                     /etc/passwd                                  9                   j       n                                       b               4               |                                                               C                           password full
name shell
     password                                  ?                                                                                v           B                                               b                               #                                                       N                               `

                 g           D             ?                    D                           9



% yppasswd
Changing NIS password for Jacky on roxy.
Old password:
New password:
Retype new password:
NIS entry changed on roxy

A        P                   J

% passwd
( %   b                                                D                                            }




                 O                                              D                   =                                               g                           D                               g                               @       -                       |               W   ?



    1^       Q           5   v                             3    /etc/group                          9           j                           :                               (       C                                                   b           group id                                                9           r       D

                 group           ( C                            \groups"                9                               `                       :                   C




                                                                                                                                                                    3
1.1. Login                                                                                                                                                                                                                                                                                                            Chapter 1.                               s       G




                                                                                             D           4               Q               |                                                                           9                                    UNIX                                                K               -               G       8        C   -

X   |               \MtosaJKopq" \MtosaJKo12"                                                                                                                                                                                    8                C           -                       D                                                   ?       B   T    Y       C   i

                            b            6                   !                           D                       K                                       C           -                   T       !                           D                                    m                                                       T       |                        C   v           2
    |                       z       Z       C                                            9                       !                   K                                   3           K                   D                                                ^                                   h                               |       :               UNIX
b   9       N       9                       D                                                                L                                                                                       D               ?                                        T



        full name                                ?


% chfn


                                                 3                           full name                                                               O                                                                           y                    full name                                                                   |                   Z

                            b                                            .               Z           D                                                                                                                       3       @                    9                                       G                       t       ?

                                                                     1




        shell                   ?


% chsh


                                                 G                                           Shell                               A           /bin/csh                                        Q                       O                                                Shell                                       (                                                    9

                Shell               (                    6                                                               -                       (           C                           A           /bin/csh                                         T           /bin/sh
                y                                                -                               (           C                  /etc/shells      :                                                               9                   j                            A                   ^           b           9                   j       n                            #

        /bin/sh                     C           /bin/csh                                                                default Shell                                                            9               1                                        ^                               /etc/passwd
            t                       4            W  /bin/sh                                          T                /bin/csh                                   |                                                   9                                                                        ^                                                           Shell
A                                                   Shell                            T                           3                     Shell                                                                                                                                                                      Q       ^                           9    t   &

9                        $                       v                   .                   w                           /etc/shells                                     9                   j                       X           |                                O                                                                   `       T                        O

?               /etc/shells                                      @                                       6               @       j                           9               1                                               1                                            |                                               C                           $        b   F   }

                         Q                                   3       9                   1                       \chsh"                                                                                     default Shell                                                         9                               default Shell
                UNIX                    `                                                                            1                                   UNIX                                    y                 Shell     9                                                X           |                          \default" Shell
    9                   Shell                                                        |                                                                                           K                       Shell                                                                                X           |                      default
Shell                                                %                                                                               c       9           3           log in                                                                                               \ "     $                                       |                           y        3   P

                default Shell                                                                                                                                                                                                            Shell
                                                                 A                                       ^                                     /etc/passwd                                                   9                   j                                            b           y           y                                           v        ^   :

        username                            3                                                                                                \ypcat passwd"                                                                          :        :                       .                                   }                           1




        @       4       1                            /etc/passwd                                                         9               j       n                       &                                                                        &                           /                           :           G                                            '

    \student1"                                         user                                  3                                                                                                               username                                                                                         _           D                                    D

         user id                                              group id                                                                                           "                                                       (                                0                                                   \ "                                     t

       login                                                                                                                                 9                           t                                               '                                    /bin/csh                                            X       |                               login
    #    C Shell                                                     D                           A                      /etc/passwd
                                                                                                                             3                                                                                                        t                                   '                                           /bin/sh
UNIX                                                                             #                                   Bourne Shell                                            /




        /etc/passwd                                      9                   j               b                                                                   (System Administrator System Manager root)                                                                                                                                                            |

    #       ?                               G                                                                )               Q           |                                                                   ?                   I        5                   b               '                                   J               W                            }




                                                                     4                                                                                                                               ?                                    '

                                                     D       (password) \yppasswd"                                                                                                           A               ^       b           9                                            J                       \passwd"
                                                     (       (full name)                                                                                                                                             \chfn"
                                                         $     (Shell)                                                                                                                                               \chsh"

            9                                                        |                                   /etc/passwd                                                                                                                                                                                                                      ?                    b

                                                                                                 P                           ?




                                                                                                                                                                                             4
Chapter 1.                                       s                G                                                                                                                                                                                                                                                                                                   1.1. Login

        ?                                        3                1                                                                       %                                       b                                                       D                                                                              \passwd"
    \yppasswd"                    \yp" \Yellow Pages"             passwd                                      G                                                                                                                                                                                                        Sun            9                   2            X    s

                            \Yellow Pages"   ]           P                                        .                                                                                                       z                                                                                                                                       (                        \NIS"
    \Network Information Service"
                                    1                             3                       |       3                       9       I       ^                           !                                   username                                            !                                   password                                            login
            D       `                                    3                                        I           ^               ?                                                       N               ^                   K                   !                                                                                                                                 3

I   ^                                        N                    user                                            ]               A           /etc/passwd                                                     9                   j                                   N                       I       ^               K                       !                                 |

                    3                   -                     ^                   r                                                                                                       y                                                               ^                           login                       9               K                       NIS
    y       9                   s                                                                         ?           b                                                                               ?                   |                   X       |                   *                               9           UNIX                                        K    2

    .       h                                3               NIS              s                   G                                       D                                                   b                                                                   3                   \           |       G               N               I               UNIX              ^        K

b                                                                                             1                       N               I       ^                       K           b                       /etc/passwd                                                 j                   A                                                   ^

3   ^                                       /etc/passwd                                                       b           (   C                                                       ^                                               3       ^                                           /etc/passwd                                         b           (       C

D   `               3           ^                    \passwd"                                                                                             ^                                                       ^                                           ^           ?



                3           b                    NIS                                                                              ]       K       /                           w           3       X                                   NIS Server                                                                                          ^                                 X

client                  ^           b                        1                                        /etc/passwd                                             9                                   j           n                   9                           ]                                   3                           `                       NIS Server
                                X       |                                                             |           3               X                                           ^                               0                                                       /etc/passwd                                                                             1             :

/etc/passwd                                                               ^                                                                                                                   9                   ^                                                     NIS Server                                                    X       |                             :

          /etc/passwd                                                                                                                 ^       b                                       username                                                                        Q      login        |



                                                                                                                                                  ^                                           NIS Server                                              ?                   :           : /etc/passwd                                                                             %

                                A                                                 b                           NIS                                                         |                   \ypcat passwd"                                                                                 passwd                           J                                             j        T

            \ ypcat passwd j grep                                                                                                 username"                                                                                                       T               3           /etc/passwd
                                        passwd                                                                                            yppasswd                                            b                           !                                                               1                        yppasswd                                                         NIS
            ]                            passwd                                                                                                               ^                                       /etc/passwd                                                         ]                       A               3       9               ^                                 ^   b

            ]                                                                         ]       T                       3           NIS Server                                                      \                                                                          NIS  ?                                               ]                   9       `            passwd
  yppasswd                                                                                                                    D                           0                           3               X                                               ^                  /etc/passwd                                                          b                             ]

passwd                                                       9                    j                                                                                   NIS                                         ]                   9       `                       yppasswd                                                                                        NIS
!



        P               A                                         A                       b                           NIS                                                 yppasswd                                            9                                                                   D                           v                                   3

    |           login                        ^                                                |                               0               ^           b               yppasswd                                            9                                   T                       ^       b               NIS                                         passwd

        ?                                            9                                                .               login                                                                                           A                                                       ?                                   NIS                 T

|   0       0                           8    n           h                            T                                                                                                                                       h       |               C Shell                                     1                E                          A                                          C
Shell           T           T C Shell                                 b           K           I           5           /                                           b                       &                   E                           \                                                                           3               |                                2    ]

                                             F



        /               G                                                     1                           login                                                                               r                   prompt                                  b                                           K                                   prompt
                                                                                  A                                   W


I Hate UNIX >


9           Q                           |                                         9                                                                   |




set prompt = 'I Hate UNIX > '


n   y       '                           (                                         4                       3           9                                                                           3               C Shell                                 a                   ?           ?           @       ~



                '                            default Shell                                                                C Shell /bin/csh                                                                                                                                        login
                                                                                                                                                                                                      5
1.1. Login                                                                                                                                                                                                                                                                                                              Chapter 1.                                                      s           G




            X       b                       K                           b       n                       UNIX                            Z                           2       ]                               -                       @           .           &                                                                           ]                                   '

                    (                                                                   \del ABC"                                                                   .           ABC                 9               j       n           l               *                                                           !                                                \del ABC"
                    .           ABC             9               j           n                                                                                               |                                                                               %                                   y                                                   UNIX                                (

                    G                                           Shell                   &           y                               UNIX                                                                                                                                        X           |                                                                       %

            (                               ?       ?       >                                                                                               |                                                                                                                                                                                                           1                   \del"
            \   l       j       n       "           X       |      \del ABC"                                                                            `                                                           $                          \                                    l           j           n           "                                                                       J

>                                           1               \del" \      "                                          j       n                                                   X       |                                               \del ABC"                                       `                                               Q               \               j           n       "

        X       |                                                                                   ?                   >                   ?                           $                   ?                                                   |           D       D                           -                                               $

                                                                        ?                                           v           9               >                                                                       g                        ?                  t       &                                               x

                    J               9               >                                       G           K



        9               >                               G                                                                                   b                                           j           n                                       >           n               E                               9                       >           n                           \.cshrc"
3                   \ "(Home directory)                                                                                                                                 '                                   C Shell                                     8       n               (




                                                                                        3               UNIX                                                            \.cshrc"                            9                                       '                       (                       j           n                       {           K                   |               \."
            (            \.cshrc" \.login" \.xinitrc"
                            A                                                                                                                                                                                       9                   |               \."                                                     (                       j           n                           2               j

                    \ls"                :    \-a"
                                                j       n           (                   `                               m                                       9                       4       (option)                                        :



                                1               3                                                   r           `                                                                                               System Administrator                                                                                            |                                           SA                  K

Q                   n                                               X           3                       \               (                                       \.cshrc"                        j




                3                               \.cshrc"                                        .                   3                           &                   b                       +                                   a                               &                           .               login
                        b                           B       s                                   b                                           login                                                                                                                                               P                       f           A           1                           #                               X
Window                              T                   Openwindows                                                                                             T                           K                                           \Good Morning"                                                                                  C                                   b                           Q

                            %                               9                                                   j           n       \.login"
        )       (               L    \.login"                                                               3           login                     \.cshrc" \ "
                                                                                                                                                    `                                                                               #                                                                                                                                   %                   1       \
    "                   .         \.login"                                          @                                       user        \program"         C Shell                                                                                                           |                                                       +                           W                           P       (   &

                                C Shell Script)                                                         N                   g   login \.login"                                                                                                                      g                               v                       b                       g           t           &




       \.cshrc"                                                 !                                    \.cshrc"          C Shell          \ "     3           N           g                                                           `                       K                                   :                                                       X       |                       N       9

    gC Shell                                    f       A           1                       3        OpenWin                 comdtool xterm                                                                                                                                                                         T                                                                   C Shell
Script \.cshrc"                                                         9                           \ "     : \.login"              g                                                           Q



        b                                               z                   %                                           \ "Shell                                                                                $           %                                                                       3                       '                               B           login
3       UNIX                                                                        |           3                                               r                                   9



% /bin/csh
Q

% exit


                                                    s                   ?                       ^       %                           s                                                       ^           %                       s                                                                                                                               Shell                           9

?                           B               9                                                                                                                       login                           `                       3           t                                       Q                       A                                               A

            (/bin/csh)                                                                  ?                                                                                                                           (                   3           t

                    -                                                   3                                                                                                   $                                                                                               X           3                                                               |        9

1                           /               t                                                   Q                                       |                                                                                                                                                           \/bin/csh"                                                   Q

|                   \exit"                                          /                   t                                                                       3                                                   K       .                                                                                               .                                                   K




                                                                                                                                                                                                6
Chapter 1.                                              s               G                                                                                                                                                                                                1.2. File System - A Short Trip

$                                                           $               X           |                                                                                                                                                           \exit"                       g                                                                           3

P



        G                                       1                                                   default Shell                                                           ^           n                                       default Shell                                                    t                                   $                           login
            3           9                   $               Q                                                   |                                                   K                   $                                           3                                                                                                                        UNIX
c           9                                                                   $                                                                   f/etc/passwdA   1                 /bin/sh       3                                                                    t                           4                                   W

                        Y                                         tcsh                                          $                   .              DOSKEY           b           \chsh"
                                                                                                                                                                                v                                                                                                                                                                            ^

default Shell                                                   /bin/sh                                             W               /usr/local/bin/tcsh       tcsh        /usr/local/bin                                                '                                    w           3                                                                   9

                        .                                                                                                   ^       b     /usr/local/bin/tcsh
                                                                                                                                                .                  /etc/shells               login                                                  w                                                                ^           n                       |

                                                        tcsh            /                               K                                          log out                                                                                  c



% /usr/local/bin/tcsh


    ?



                                3                               %                                                                                                   Shell                           $                                                                                                                                9               .

M           $                            9                  %                           L                                   3       T                       f               z




                    /                       login                                                               G                       1                       b                           \.login"                                j           n                3       \.cshrc"
                            g                                                   login                                                                           `                                       g                   A                                                g           $                                                       \.cshrc"
g           \.login"                                            .                               9                                           g           $               9                                               g



        X           |                   \.login"                                            |                                                                           3           \login"                         `                       W                                                A                                               *       F                `

^                                   `                       T                                                   1           \       H                                                   b                   G                                           \login                               #                                   "                                    |

    3       \ .login"                               j       n                                                                       Z           C                           W



        J                           login                                                       W                                                       -               3               System Prompt                                                                            W                                                   T               1

    t                                    $                          n                                                       9                   $




        n       y                   C Shell                                                             |           C           \.cshrc" \.login"                                                                                                        b               9                       D                       .                                   3        v

b                                                           a               &                                                                   S                           .
                                                                                                                                                                                                2

                                                                &                                       -           I                                       UNIX                                        (                   :   :                   9    9                                                                   b       %                                :




1.2 File System - A Short Trip
    3       &                               G               G           UNIX                                                                UNIX                                    j       n                                   @       f                5                                       .               B                                   X       |        4       1

9                       (                                           E                                                                                       &                                   j       n           X                                    L           Q                                       R               ?                   T   T       W



        UNIX                                                                                                m           T                kernel                                                                 &                                                        !                       P               j       n                   )       R                        G

                                        C Shell /bin/csh)                                                                   C           chfn (/bin/chfn)                                                            K                                                    P           i                                       D       3

H           2                                                                                                                                                                                                                                                                    UNIX                            j       n                                        b

v   E                   |                                           K       &                       b



        UNIX                                    J                   j       n                                                       3           \root"                                                                  \root"                                               1                                           5                                            1


    2           h                       |   C Shell                                 1                                           !                   $       b           !               \   @               "   j       n           \.cshrc" \.login" C ShellC                                                               9               $           @        '       j

A                                       Shell     /bin/csh                                                          9               1                                       H                       y                                       >                                                    8       n




                                                                                                                                                                                                            7
1.2. File System - A Short Trip                                                                                                                                                                                                                                                                    Chapter 1.                                              s           G




    \/"     9           DOS                  !                                DOS                                         q                       5                                       \n"                                                   \n" UNIX               3                                                                       b

L         \/"   !       `                                                                                                                                                                      |           :           :       3               /etc/passwd                                                             9               j               root                X

3                   t                                 3                                               f                                                           j           n                                            &                           3                       :




/bin                        9           binary                                                    3       F                                           UNIX                                                                         9                                               D           w                                               (user)
                                           (command)                                                                  .                       A           h                       b                        UNIX                                                            A                   SunOS)                              -       .       9

                                                      K       h                                   /usr/bin                                        9                                                                            9                                                           9                                                                               P

                                                                                          b                                   P                       T                                   Y                                H               /bin                                                                                    l                               -

                            9                    (                                                                            Q                       3                                                                            @                               2                       1                       9                                       3

                                                     /usr/bin                                     0                                                                                   9                                2                           ]           P       3                   UNIX                                    &               ?               v

                                         b                    b       (                                           \link"                                          =                                A                                           \ls -l /bin"                                                                :

                            :       :
                            % ls -l /bin
                            lrwxrwxrwx 1 root                                                                                                                                 7 Jun                                    3 01:26 /bin -> usr/bin



                                    \->"              r                                       \/bin"                              X           3                                                        H                               \/usr/bin" link                                                                         3           UNIX
                                                                              9                    /bin
                                                                                                      1                                               9                                                                                    =                                                           |                           \           H       !       h       "
                                                                              Y                                   j           n                        H              (/bin)                           T                                                   H           (/usr/bin)                                                                  |

                                         b                    Y               )           Q                   |                                       5           W                       .                    9                                                               @                       !                                   V                       !

                                                              b                                               b               n       =                                                                        a                                                               +




/dev                        9           device                                                            9                                                                                        X               b           UNIX                                                            \           -

                                    UNIX                  E                       \               -                                               H                       A               !                                                    j               n                                               X       |                   b           /dev                9

                                                 9                b       &           P           &                                   (           C                       &               E        T                       8           n                               \               '           n                           A                                   ^

                            /dev/rst0                     {               ^                           /dev/rsd0                                                                            t           h                                       9                                                               D       3                           P       9       A

                            /dev/null                     b       n                                                               \           &                       3                                            :




/etc                        9           et cetera                                                             9                                                                                                                                        X           m                                   j           n

                                                              3       9                                                               j               n                                   G                                                K                                               \passwd" \shells"
                                    @            `                                                            \rc" \rc.local"                                                                                  '                                           ^                                \inetd.conf"                                                   '

                                ^        \printcap"(BSD                                                                                   UNIX                                            b        )                   n       y                                                             \aliases"
                                                                      9                   j           n           |           C                                                                                                                                                }                       1                   9                               y

                                                 2    8




/home                               !                                         &                                                                       (home directory)                                                                                             N                                                                       b

                                                 X    |                                                                                                                                            3           9                           .           h           9                                               3

                                D   3




/lib                        9           library                                                                           D           w           &                       P                                                                                                                C                                                                       P

                                                      P               C           j           n                                       /bin                                                                                                                                                     w                       /usr                                        W

                            /usr/lib                          Q               \link"                                          =                                                                        K                                                               1               3           9                                                       /lib
                            /usr/lib                  !                       2           ]




/lost+found                 9                                                                                                             j           n                                   s                                                            A                                   C           W                                           ^               3       ^

                                         @            `               b                   j           n           0                                               w                       2        ]                                       P                       0                                               j       n       -               w       3       9

                                                 X    |                           \lost+found"                                                                                                                                                                             9                       P           x                                                           h




/tmp                        9           temporary                                                                                                 w           H           &                    !                       P                           `               X                                                       D       j               9               3       J

                                    UNIX                                              K                                                                                               |        D           w           j       n                   2                       2               ]                                               K               |       D




                                                                                                                                                          8
Chapter 1.   s           G                                                                                                                                                                            1.2. File System - A Short Trip

                 9                        X       |       b                                           t                                                                                                                    9                                    W                   w   j       n

                 2   ]            9               E                                   0                           |           .                                                   {                                                                                                                 I

                                                                                              9                           K                                                           v                                                         ^               9                                   j

                 n                                        z       t                           Q                           b                                       3                   ^       `                                    z        9                   j       n               P           A

                             .    9                               W               |           D       w       {                       j       n                   2       ]




/vmunix          9               virtual memory UNIX                                                                                                                  UNIX                             m           T           (kernel)                                     2                       _

                 ^                S               UNIX                    @                   `               j           n




/var             9               various                                          9                                                   b                                                                        D           w                                    `                   ]           9

                     ]            `   3                           b       `       m                                                                                           z           t            |                                                5

                 f




                 /var/adm                     D       w                       G           >       C




                 /var/spool                   D           w                                                                                                                                       8        n           j        n                                               >       >       8   n

                                                         /var/spool/mail                                                                          9                                               3                                         D       w               &                               *

                                              O       (mailbox)
                 /var/tmp                              /tmp                   v                                                               2               vi  2       8                                            9                _                                   .                       c

                                                      (bu er)                                 b       `                                           vi          _                                                                j        n       `                                   C   W       9

                                                                      y                                   0           l           X               \system full"                                                                         ^       b           9

                                                          vi                                                  /tmp                                    !                                           ^        `                                                                        z       t

                                                      A       h                                           )           Q                   6                   T                           9




/usr             9               user                                                                                                                                                                                                   b                   J

                                      C                           P               {           K       D       w           3               /usr                                                                         /                                                                        T   j

                 n   b




                 /usr/bin                                                                                                             P                   {       K       3           h                            ls cat cp mkdir rm
                                                                                                  /bin                3                       9                                               !                            2 link   ]                                               =           3

                                                      R




                 /usr/include                         D       w                                               \                           j       " header les                                                                                  C           +               P

                                                      E       h       T




                 /usr/lib                                                                 P                           &           9                   P                           `                        9                   0                                            /lib            3       9

                                                                                          !                           2           ]                   =




                 /usr/5bin
                 /usr/5lib
                 /usr/5include                            A                                       (BSD)                   y                                                                                                                     b           9                                   9

                                                                                       /usr/bin /usr/lib /usr/include                                                                                                                                                   !

                                                                      y           System V       (      UNIX                                                          n       y                                                                             3               a           b           j

                                                      1                       )
                 /usr/ucb                             w     BSD
                                                              b                   lpr vi                                                                      A                                                        nger                                     ucb                     Univer-
                                                      sity of California at Berkeley
                 /usr/etc                             D       w                                                                                                                   P




                                                                                                                              9
1.2. File System - A Short Trip                                                                                                                                                                                                                                                                                                                                      Chapter 1.                                       s       G




                                                                    /usr/dict                                                                D           w                                       C                                   spell                       9                           C           l                               P

                                                                                                                                                         s                                       H                       J           9                       C                                                                                       D




                                                                    /usr/man                                                                                 /usr/share/man                                                                              !                               2   ]                       =                                               w           b           UNIX                     a

                                                                                                                                                         W      (on line help)

                    &                                                                       %                       UNIX                                                                     2                                   P                       w           3                           2           ]                               5                           3               /bin                     /usr/bin
                                2       ]                           library                                         5           W            /lib                            /usr/lib                                                                                3           b                                   \                       .                                                       )

                    Q                                                           |           3                   R                                        %                                                   5



                    UNIX                                R           M                       `                   G           3           20                   O       G                               3               PDP-11                                                  s           "                           `                       {           P                               ^               *

            *       F           9                       ?                       3           ^                                       =        #                                                   H                                   {                                                                                                                                               \               >                "

                                                                                            >                               X                                `                   UNIX                                '                                           .           N               {                       K                                                           j       n                                    .

                                            >                                   "                                                                w                                       m           T           (kernel)                                        |           C                                       n                       j           n                       9                                    3

            @                           `                                                   b           t       ?                   D        T                                           9       {                       >                                   X                                                                                                                   userw                            b   n

            ]                   9                                   {                                   5                   ,       3                                    \/" \/usr"          C                                           9                                                                                                           1                       \/" \/usr"                                   @


                                        !                                                   {



                                y           9                           a                       .                                                                                        {                       *                                   M                       3                               {                                   |           =               b           GigaBytes
                                3  Sun          kernel                  ^                                                           A                                                    m           T                                                                                           UNIX                                @                           `                                            X       3

                    {              partition \/" \/usr"     &                                                           .                                                                        W                           C                                                       I                               Q                                   3           b                                            \/lib"
            \/usr/lib" \/bin" \/usr/bin"       \link"                                                                                                                                @       \                                                       3                       R                           -       3           9                           (           C           i                       b                UNIX
            J                   B    partition \/" \/usr"                                           ^           b                   {                                                                    W                           C



                            /bin /usr/bin /lib /usr/lib
                                3                                   :                                                                                                                                                                                                                                    9




                l           +                                                               UNIX                                     j       n                                                   b                       ?                                                                       %                                           |               3                       9       ^                login           v

X   D                               j       n               K                       !                                           f        A       1                                   ^                                           ^                                       login                                                                                                           :                                    K

                                                        ^                       ?                       ^       n                                                            W                                           3           1           %                        NFS                                     mount                                                              9                    M           (

                                        Sun                     2                               s                   NFS NIS(YP)                                                                                                                                      A           G                                       X       1                       NIS(                                (           YP)                  |

3           !                   ^                       K                       |           r                   (login) NFS Network File System                                                                                                                                                                                              J                                               |       3            !       ^

    ^       K           :                       !                                   j           n                   f           A        1                                                                           w       3               ^                                           {                                                                           ^                               r

                    |                                               D                       D           w       3           ^                                {                                                                       9                                   F                   PC                                                              F                                                            n   y

NIS         C               NFS                                                                                                                                  3       9                                                       +                                                       P               H       9



                                                    r                                                                                                                                                                                                            X           3               H



        ?                               E           y               \                           " UNIX                                                                           T                       b                   F               F                   F                           3                                   a                       &                                           :   :                t

                        \                           "       b                                                                                                            1                                               %                                                                           \                           "                               .                               3       UNIX
                                    X                       \                               "                           @                                        9                                                                                                                   P                           b           K           I           5                                   y           $

                        }                                                   P                                           \passwd" \chsh" \chfn"
                                                                                                                        /                    3           $                                                                               1                                                                                                                                                                    K           }

            P                                           &                       3           \/bin/passwd" \/usr/bin/chsh" \/usr/bin/chfn"                                                                                                                                                                                                                                                            1                    |   3

UNIX                    j           n                                               0                      \set" \source" \alias" \exit" \ "                                                                                                                                                                                                                                                                      3       UNIX
    j       n                                                                                   ^           b                 \ "        E           T               }                                   P                                                                               y           $                           /

$                                                                   P                       f     C Shell \/bin/csh" Bourne Shell \/bin/sh" 3
                                                                                                        A



        3                                                       a                       G                                                            A                                           UNIX

    33                  h                                               1                   ]       -       R                                                            5           9               }                                       P               $               /                                                       |           \                       "

                                                                                                                                                                                                                         10
Chapter 1.                      s               G                                                                                                                                                                                                             1.3. Logout

1.3 Logout
                    UNIX                        b           9           ]                                                                       PC                              n   *




                                                                                                                E                           |       n       *                       !!

t                                                                                       b                           T                                       P           3                   n           *                                     9               9                       P

                !
                                        .                       UNIX                3                   `                               b       &       9       j           n           8       n               ]           ^       b    y            /   {

w   3       B   7           /       9                   ]           3                       `       ^                           /           {                           ^       b                                       #           `             A           -           n       ^           9

            ]   -       b                   *           0       l   j           n                                   B                               9                f              ^       ?                                                                             q       A

    B                           PC                  UNIX                        W                   1           b       n           ^               \ " ?                       Y           9                                                             |       3                           c

    G       0                       n                                       n       *                               9           `                                   W                                               \                   :::

        t                               ]                                               \exit"              9                                                                                       r                           r       (login:)                      c           (
    B                                                                       g                   0                           n



                    a           &                   :       :                                       \                       "




                                                                                         Bourne Shell(sh), C Shell(csh), Threaded/Tenex C Shell(tcsh),
                                                                                                     Korn Shell(ksh), Public Domain Korn Shell(pdksh),
                                                                                           Bourne Again Shell(bash), Z Shell(zsh), Almquist Shell(ash),
                                                                                    Extensible Shell(es), Plan 9 RunCommand(rc), Steve's Shell(ssh): : :
                                                                                                       :::    UNIX                          \ " !                   3                                   t   &                                 E               P               $           p


                                                                                                                                        by JS (Who?)




                                                                                                                                                11
1.3. Logout        Chapter 1.   s   G




              12
Chapter 2

+                               UNIX

|                                           }       J                                                                                                                                                                                     |       C           P                   b

UNIX                            H       9                   H           p           B                               @                                                                                     J           UNIX                                        @           ?   B        9

    J               UNIX                                                        {           K                   |                           P


                                                            (                                                                                       n           4

                                            (Command)                                                                                           (options)                                                                     (arguments)


        I   5                   a       K       3                               \                   4       "                       G                   b               \-"   r                                   (                           4       J   {       K           z   Z

            B               9                   J                                                       a                           (man                                 )    ^       %           p



                                                                                                            f                                                   |       1                 \                   "   9                                                       |

    Y           UNIX                                                                    y       :                               ?                           9                                                             ^                           .                                        B

R                           :                   b                                                               |                   ^       b                                     :                                   A       C                   !       UNIX
            !                                   T                                               K                   k                   (       C                       K                     b                                   `           ^                                                9

            Q                   X   |           1                   !                           UNIX

                                                b                   9               UNIX                                                                @   K                     a           P               n       7                                               &               UNIX
            |                                   |                               Q                               \man"               9                                                                                                                             %




                ]       -                           X           |           |                               ]           P   J                                                                     F       +                                           5           l               &

                                                                                 .                                                                          1                                 (                                                       1   I       5       )   2        z   Z

                    A           C               I       5                                                                                                           |                                                                 (




2.1                     -                   :           :




                                    1                                                                                                                                                                 P

ls                                  list                                                                                                                                                  ls -la
cd                                  change directory                                                                                                                                      cd ../../dir1
pwd                                 present/print working directory                                                                                                                       pwd
date                                date                                                                                                                                                  date
who                                 who is logged in on the system ?                                                                                                                      who
whoami                              who am i ?                                                                                                                                            whoami
more                                page through a text le                                                                                                                                more   /.cshrc

                                                                                                                                                                    13
2.1.   -     :   :                                                Chapter 2.   +   UNIX

cp                   copy les                                cp file1 file2
cat                  concatenate les                         cat f1 f2 > file3
man                  manual pages/On line help               man man
alias                alias a command                         alias ll ls -la
history              display past commands                   history
setenv               set environment variables               setenv DISPLAY v0sun2:0
set                  what is set in this C Shell ?           set
stty                 set terminal type                       stty erase ^H
lpr                  print a le to printers                  lpr   /.login
lpq                  printer queue status                    lpq
mv                   move les around                         mv   /.cshrc   /kk
rm                   remove/delete les                       rm -r   /.junk
mkdir                make directory                          mkdir dir1 dir2 dir3
rmdir                remove directory                        rmdir   /dir1
mail                 mail                                    mail john < letter
exit                 exit a shell or the system              exit
chmod                change a le or dir's mode               chmod 755 batch
which                which one                               which openwin
vi                   visual editor                           vi ~/.cshrc
ps                   process status                          ps -aux | more
kill                 kill a process or job                   kill 898 kill %2
grep                 global regular expression print         grep "set"   /.cshrc
df                   disk space in file system               df | more
du                   disk usage                              du ~/my-secret-dir
telnet               connect to another system               telnet 140.111.1.1
rlogin               remote login to another system          rlogin v0sun2
rsh                  remote excuting a shell command         rsh v0sun2
  nd                  nd les                                 find dir1 -name file1 -print
compress             compress les                            compress big-files
uncompress           uncompress les                          uncompress File.Z
uuencode             UNIX-to-UNIX encode                     uuencode f1 label > f1.uu
uudecode             UNIX-to-UNIX decode                     uudecode f1.uu
w                    who is logged in ?                      w
su                   switch user                             su v10xyz
wc                   word counting                           wc -l   /.cshrc
env                  display all the environment variables   env
di                   What's the di erence between 2 les      diff file1 file2
cmp                  compare 2 les                           cmp file1 file2
tar                  tape archive                            tar xvf tar-file.tar
head                 the rst n lines of a le                 head -50 this-file
tail                 the last n lines of a le                tail -50 that-file
cut                  cut down speci ed elds of a le          cut -c1-3 f1
paste                paste together 2 les line by line       paste f1 f2 > total.cmp
split                split a le into pieces                  split file1
tr                   trslate characters                      tr 'a-z' 'A-Z' f1 > f2
sort                 sort data                               sort address-book
cc                   C language Compiler                     cc -g -o test test.c
whereis              where is the source                     whereis cat
nslookup             name server look up                     nslookup umc.com.tw
tee                  T                                       make -f mfile |tee log
  le                 What's a le's type                      file /usr/bin/*
touch                update a le's date/time                 touch file2
ln                   link                                    ln -s   /f1 ./f2
unlink               unlink an existing link                 unlink ./example

                                                     14
Chapter 2.                   +                       UNIX                                                                                                                                                                                                                                        2.2.                                 .




expand                                   expand TAB to spaces                                                                                                                                                 expand tab_file > f2
uname                                    unix name                                                                                                                                                            uname -a
expr                                     evaluate expressions                                                                                                                                                 expr 1 + 2




2.2                                                          .




             l       +               &                                                                           +                   t                                                                4       (option)                                 &                                                 4                        \        3

b    m       `                               man                                     man                                                                                                                  b                   \                                                                  !                           +             ^

         $   5




                 .                                                                                           :                               g                    b                                                           $                                 `                        /               :                   ?    z

T                        |           J               9                       h                           \                   ^                       \                                                                                 ?           ]                                                     0                            g

I    .               .                               b                               H                                   ?
                                                                                                                                                          1


ls                               &               A                               B                               DOS                                  T                           B                                               .                                                                  dir             T           DIR
                                             dir                     %                                                                                                                                j       n                                3            UNIX                                         8       E       y       dir
                                              \ls"    list                                                                                                    A                                   :       :                                                 b                    j       n                               |        9

                                              \ls" ls                                        t                                           4                    \a" \l" \F" \a" \all"                                                                                                                              .       2        j        j

                             (           |    \."                                                                            R                                   \l" \long"                                                                                     .        j       n                                       ]   A    j   n

                                                         g                                   ^                                                                  \F"                       J                       j           n        l           V        3   j        (                                                            r    |

                                                                     *                                                       j                   /                                                @                       =



                                         UNIX                                                                    4                   |           5                                                        H                            |           )        3            R               X       |       \ls -laF" \ls -
                             aFl" \ls -l -a -F"                                                                                                                                               A               \ls -la /usr/bin"                                                                          \/usr/bin"                   9

                                                                     X           b           j       n       (       C




cd                           change directory                                                                                                                                                                                                        DOS                 8       !

                                         T                               b                                               2                                                    A                                                                    \/tmp"                            T                       9                            \cd
                             /tmp"                                   A                               3           cd                                  ^        b                               2                                                    \cd"                  J                                       2

                             9                   F                       DOS                             !                       3           DOS                                              cd                                       G           X       3                                                         3       UNIX
                                                                     G           X           3                                                \pwd"                               9




                                                 3       UNIX                                                b                                                    5       b       n               \           r           "   m            3                                     -       I       z



                                             .                   \."             3               UNIX                                                    \            G                       5                   H       "                                              \pwd"                                   :

                                                                                                 X       |                                       `        3                                                                                                \ "       X



                                             .. \.." UNIX                            3                                                                        \           G                           5         "                                           T            \                           "                   A            3

                                                  \/usr/lib"     3                                                       9                                5                                             \cd ../man"                                                                      \                       /usr        9

                                                      man"                                                                                                        1                                   cd /usr/man
                                                                 \ " UNIX                3                                                                            \                               "               X           |   \cd              ~/mail     "
                                                                  \mail"                                     9                                                                                                                                                  3username                                                G

                                                                       user                                                                                              \ john"      A                                                                    \john"     user   9

                                                                 A   \ "                 3                                               ^                        username                                                                                          home directory

date                                                     *           F                       ^               C                   G       `



     1                       9                                               b       F               9               A               :                                                    >                                                    a       :    :   \8                           "       a




                                                                                                                                                                                      15
2.2.                          .                                                                                                                                                                                                                           Chapter 2.                                              +                               UNIX

                      % date
                      Mon May                                         8 19:32:19 CST 1995


                                                  b           `                                                   `                                                                   `                                                       l                                               L                                   %                               .            UNIX                ^

                                                  `                                                                                           @                   N                                           `                                                                                                                   '                                       |

                      `                           -                   G




                                                                                      s                   3                           -           O                               G                       b                               C                               |                     \CST"                 1                                                                            9

                                          C                                                   `                                   f               A       1                   }                                                                   `                               Greenwich Mean Time
                      r                   \GMT"                                                           X               3                           `                                                                           `                               &                          SUN          A                                                                                        3

                      H                   `       A                                                       @                       `                                   C                               C                                           X           3                   `                                           9                                   z       Z   C                T

                                          \CST"                                                                               Y                                           I                                   `                                                                       \CST"                                   3                                                                    9

                                  `                                   H                                                                                                                                           (Email)                                     3           N                                                                               !               9            `

                      X           |                                   s                                                                                                       s                                               *                   3           Y                                       B                                                           `       u   |                    *

                                  B                           `                               :                                                   s                           b           Q                                                                                           mail                                    Q                                                                    9

                                  -                                                           b                       g                                                     News post
                                                                                                                                                                              3                                                                                                        article                                                                                                 3   Y

                                                              2                               /                                               2                           News                                                                                                                            1                       &               X                           news mail
                                          `                           .                       P                                               2                            news server                                                                                                    server                                              m                           z    t

                      article                                         E           y                                               `                                           Q                                   ^                   F                   X           |           C       W                                                   W                               s                    g

                                                                                                                                      SunSoft                                         ^                               b                               /                                               .                                       ^                                v                   p

                                                                                                                                  y      \CST"                                                    9                               W           %                               T                                       \CST"                               ^                                    X   3

                      `                                                           9           T                               %                                   ?       ^                                                                   A                   \                                               9                                                            n               j

                                                                                                                  3                                           HP                              ^                                               `                   T                   K               '                           \EAT")
who                                                                   3                                           9                                                                   b



                      % who
                      Jacky                                           console                                     May                         10              10:19
                      John                                            ttyp0                                       May                         10              10:19
                      John                                            ttyp1                                       May                         10              11:09
                      s20cjs                                          ttyp6                                       May                         11              16:12                                           (140.113.68.150:0.)
                      root                                            ttyp9                                       May                         11              10:17                                           (roxy)


                      3                                                      5                        N                                       &                                                                                                                   '       n                   |

                            \Jacky"                 \/dev/console"                    5 10        9                                                                   3                                                                                                           9                                           '           n                   `                            `

                      ^  10 19                \who"
                                              F                           5       R \John"                                                                                                                    `                               c                                                                   C                                                                                9

                                5 10 10 19                 \/dev/ttyp0"
                                                              y                   `                           ^                                   F                       5           R                                                                                                                   9                                               '       n                                y

                      5 10 11 09
                              `                  \/dev/ttyp1"
                                                          ^                          \s20cjs"
                                                                                      F                               5           R                                                                                                                       9                                       '           n

                      9          5 11 16 12              \140.113.68.150"
                                                                      3       IP              `                               ^                               F                           5           R                                                                                                                   9                                                            D

                      \           \/dev/ttyp6"                       \root" 5 11 10                                                                               9                                               '       n                               "                                                                           3                       `                    ^               F

                      17            \roxy"
                                      5       R                         \/dev/ttyp9"
                                                                              (                                                                       9               ^                                   D                               \                                                                                                                                    9

                      '        \who"
                                  n              \/dev"                            \ttyp0"                                                                        B       .                                               6                                           .                           '           n                           (           C               A




              X   1           \                       '           n           "               @                                               h                                                                       9                                                       &                           \                               ^           "                                        |

  f       y               Z           C               1




      G       1               UNIX                                                            9                   9                                                                   3           !                   `                                           b           9                                                   3                                                            b

                                                                                          !       `           3                                       9                           f           A           1                                   UNIX                            ^                                                                           3       _            j       n

          3                                   P                   !           `                   3                                       j           n                           9                                                                           !           `                   9                   9




                                                                                                                                                                                          16
Chapter 2.                              +                       UNIX                                                                                                                                                                                                                     2.2.                                             .




            .       N                                                                                                                                :                           A                                                                                                   !       `       3       \ls"                              j

n                                   m                                                                                                                    /                   9                   /                   K                                                                   \                   '           n       "             &

                    K               :



        X       |               3       N                   g           b                                login                                       `                                                   N                                                               ^               N                                   ^                 _

r           Q                                                                       %                                        %                                                                               ^                                                                   m               X       /

^                   9                                           N                                            T                           !                                                                               !                       ^                                           !       8               W



                                ?                           UNIX                                                     9                           ^           T                           9                           `                           b                                                       b                                `

            -                                   2       ]           0                                        ^                                                   9                                                                       E                           9                               ^                   w       3        /dev
9                                   |       \ls -l /dev/tty*"                                                            :       :       b   9       K       /etc/ttytab                                                             9                   j       n       J       !               9                                   ^

E   T               &                                               )                   9                                                            /etc/ttytab                                     j           n                                       Sun                                     X                                       UNIX
(SunOS)
# name                          getty                                                                                                                                    type                                                                    status                              comments
#
console                         "/usr/etc/getty cons8"          sun                                                                                                                                                                              on local secure
ttya                            "/usr/etc/getty std.9600"       unknown                                                                                                                                                                          off local secure
ttyb                            "/usr/etc/getty std.9600"       unknown                                                                                                                                                                          off local secure
tty00                           "/usr/etc/getty std.9600"       unknown                                                                                                                                                                          off local secure
tty01                           "/usr/etc/getty std.9600"       unknown                                                                                                                                                                          off local secure
tty02                           "/usr/etc/getty std.9600"       unknown                                                                                                                                                                          off local secure
tty03                           "/usr/etc/getty std.9600"       unknown                                                                                                                                                                          off local secure
                                       ......................................
tty0e                           "/usr/etc/getty std.9600"       unknown                                                                                                                                                                          off local secure
tty0f                           "/usr/etc/getty std.9600"       unknown                                                                                                                                                                          off local secure
                                       ......................................
ttyp0                           none                            network                                                                                                                                                                          off                 secure
ttyp1                           none                            network                                                                                                                                                                          off                 secure
ttyp2                           none                            network                                                                                                                                                                          off                 secure
ttyp3                           none                            network                                                                                                                                                                          off                 secure
ttyp4                           none                            network                                                                                                                                                                          off                 secure
                                       ......................................
ttyTd                           none                            network                                                                                                                                                                          off secure
ttyTe                           none                            network                                                                                                                                                                          off secure
ttyTf                           none                            network                                                                                                                                                                          off secure


                            s                           t                       \                                \ttyp??" tty                                                \terminal type"                                                                                                     t                                       \p"   J

  \pseudo"                                                                                                                                               ^                                                   a                                       ^                                                           Y

login                   9                               t                                                .                           G           I       5                               K        b                                                                                      K       D

UNIX                                        X           |                                       \who"                                `           :                       ttyp                                                b                                                                                               i       r

                    %                               5                                                            s                                       b           ttyq ttyr                                                               #                                                                               \pseudo"
  \p"           C                                                               .                    b           ttyp0 { ttypf                                               |       T           }                                   9                                   m       O                               g

login                                       UNIX                                                 Q                 \Out of ptys"                                             G       >           `                           T                                                           .               X       b

a                   ^       K                                                       `                                    X       9                                               |                    \w"                                        :           :

    t       9               a                       ^                   Q                            n       *                                                       a                       ^



        3               9                       '           n                               /dev/console                                         t                                       t                                                                                                       =       #        x          ^

            ^                                       K                       "       8                X           |                                   I               UNIX                ^                           b           D                                                               ^       b                   3            ^

X           #       =       #                                   ^           G               ^                                            9               /dev/console                                                                                                                        A                               b       %

            \                   "           f       A           1                                                                                        .       G       >                                       console                                                     X   |               b       `                                s

            ^                                       K                                                                                        G       >                           .                                                           3                           /dev/console                                                `

3                   `                                                                           console        console                                                                               B                                                                                       ?                       0       2       ]

A                                       Sun                                                          OpenWindows                                                         ^   b                                   console                                                                                             $                    K




                                                                                                                                                                     17
2.2.                                        .                                                                                                                                                                                                           Chapter 2.                                                  +                           UNIX

                                        G           >                   B           *                               refresh                                         K                                               .                   K                                                                               .                                                               console
                ^                                                                                                                                                                   ?                                                       {                       .                                                                   G           >           ^                               X

|       console                                                             -                                               A                                                                   B                                                                                                                   A                               3               X Window
             xterm                                                      \-C"                                    4                           A                       \xterm -C"                                                  Sun
                                                                                                                                                                                                                                3                                               Openwin                                         /                                      \cmdtool
                                                                                                                                                                                                                                                                                                                                                                        |

-C"                     A                               3                               /                           E               R                                                           R                           console                                                                                             1                       9               ^                   9

        b                   P                                                               ]       -       i



            3           &                                                               Y               |           G                                                                   1                   John                        9                                                                                       \/dev/ttyp0"
    1                           P                                                                       .                                                                                                       5           g                                                                           ^                   9                                   @               1       E

                    Q       P                                                                                                               ^                                                                       Z           C                                               Q                                   |

                    ^                                       G                                                                       \John"
                                                                                                                                        '                                                                                           A                                           \ls -la > /dev/ttyp0"                                                                                           |

                                                                                                                        \/dev/console" 2
            b                                   M                                       ^       (                   \/dev/null"                                                                         E           "           A                                               X           b                                                                                           K

                                        \                       "               3           |                           a                           &                               :               T



                                                                                    !                       UNIX                                            b                   !                                       ^                           ]                                                               9                       X                                   |       SunOS
    x           A                       X                                                                                   SunOS                                       3           b           ]                                                           b               }       &                       !                                                                       F   8

A               E                                                   @           3                   H                                                                                               9                                                           (                                   UNIX                                                    F




whoami                              )           (               L                                                   @       -                                                                                                                                                   username                                                                                                        Q

                                                                                            username                                                                                                                                                        b                       F                                           `                               Q

                                                                                    A           1  \su"                                                                                       shell           :::                                                                               3                                   `




                                                .       9                                       t                                                                       !       L               \who am i" \who am I"                                                                               T                                                                                   9

                                                                @                       \who"                                                                                       4   \am i" \am I" \whoami"              T                                                                                                                        f                  R

                                                }       P       }                               H                                               .                   X                                                           ^



                                                                s                       9                       K                                           !                                                                       option                       \-"&           Q           A           h                   +                               #

                                                r                           v                   A                                    SunOS                                                                                                  $             \who am i"
                                                                                                                                                                                                                                                                ?

                                    T                   \who AM i"                                              T               \who am I"                                                          #                               \who are you" \who x y"                                                                                                                                     K

                                                                                        .                                         \who" :                                                                                                       b

                                                \am i"
                                                UNIX                        b           `                                           y           y                                           ^
more                                9                                                           :       j       n                                                                               G       g           y           \cd" \ls"                                                               A                   :                       le1             9               j   n       /

                                                                            \more le1"                                                                  j           n                                               `                           3                       K                                                                            \--More--"                                 C

                                                                b                               y       5           f               C                                                   3                   B           :               J                   j               n                   9           K       I           5                    9          `                       k

                                                        "           <Space Bar>                                                         |           :                                               T           k         Return                                                    "                                   |                       g       9

                                                                X           X           :                           H                               :                                   |                           Control-C                                                                           Ctrl                        "                                       C       "

                                    \



                                                A               j           n                                                                       :                                       3       j           n                                                                       A                       3                       V                       100
                                    |            \more +100 le1"         100                                                                                    #                                                               :       R                   T                                                                                                   2       ]           :   R

                                                |  \more +/key word      "                                                                                  j           n           (                                           #               j       n                                   b           \key word"                                              C                       2   ]   :

                                    R                   \more"
                                                        9       `   \key word"                                                                                  b                                                               C                                                                       G                                                   R



                                                \more"                 more                 b               9                                                   A           3                                                       j           n       `                       `           X                                                                                   |           v   "


    2       9                                                                                       ^                                       a                                   p                                               G           t       ?                                   a                                   @                                               :       :   9

^       /dev/tty??                                  j       n       J                                                           %                           |       |                   ]                                                               ^




                                                                                                                                                                                            18
Chapter 2.             +                UNIX                                                                                                                                                                                                                                         2.2.                                            .




                                        vi              #       _



                                                b                                           \more"                                                  {                                                                               \page"                               \more"                          t                                   !

                       3            \page"                      3                               `                                           .                   K                                                           z       *
                                                                                                                                                                                                                                            3

cp                                  j       n                                                           A       .                       le1                                                     W                   le2 :
                       % cp file1 file2


                                       \cp"                                                                                                                                                                         A                   \ le2"                  B    D       3                                           \ le1"
                       *            .                       ^           b                       UNIX

                               UNIX                         '           A       h                                G          W                               &                               `                                                   X       |            1       \   .               le1                                         W

                           le2 "                `                                                                       @               -                   le2                     D           3
                                                                                                                                                                                                                            4           X       |       UNIX                                       \                 @       -       "
                       4    \-i"
                       % cp -i file1 file2


                       9                                            A                   \ le2"                                          B           D       3                                                                             \overwrite le2 ?"                                                                                  s

                               \ le2"                       B           D           3                                                           @       -                                           .                                   \ le2"                  *                            6           /                   \y"             .

                                   \ le2"                                       *                       T                   /                       \n"                                                     5

                               cp                   b                                   option                                                                                  \-r" \-p"                                                       :   \-r"
                       % cp -r ~/dir1 ~/dir_tmp/test


                       9                                    \-r"                            4                                                               |           C       3                                                                                    X       b       j       n

                                                                                                                                            3                                                       DOS                         9                                   copytree                                 @           3           UNIX
                       \            b       9



                                                        cp                                                                                          j       n                                                   ^                   K           '                    `                               `


                       j       n            ^                                                           A                                           1                                       j           n               ^                   3                        j       n                                                   \-p"        9

                                    4



                       % cp -p file1 file2


                                            j       n                                                                               E                                       b       `                                           m                                    j       n

                                                                                            .               3                   j           n                           le1                         le2                         le3                                 dir dest                 9




                       % cp file1 file2 file3 dir_dest


                               Y        MS-DOS                                                                                        \copy le1+ le2 le3"     le1   le2                                                                                                                                          #               )

                       R                    W                                                                   j           n         le3     UNIX     \cp le1+ le2 le3"        3                                                                                                                                                        \   .

                       file1+file2                                          9                   j           n                                file3"         UNIX                                                                    B                                                    j       n           (                       |

                       b                            M                               r                       4           Q           \+"                 rUNIX                                       H                   M                                                .                       W           j           (                   I

                       5



                               3            UNIX                                                        .           &           9           j           n           )                   3                   R                   W                       j   n                                    \cp le1+ le2
                           le3"                                                         |                               +                                   \cat"               9


     33       unix         b                            |       .               K                   `                                   9                                                   \clear"
     4         '   x       G            E                           @       j                                                   x
     5    @                        /    \y"                                                 C                                   K                                                                   n               X       |               /       \y" \yes" \ykk"                              K                                   \ le2"
overwrite          *               \n" \NO" \YES"                                                                       /                           T                       #                           RETURN                              "       K




                                                                                                                                                                            19
2.2.                                            .                                                                                                                                                                                                    Chapter 2.                                           +                       UNIX

        UNIX                                        b                                                               F                   X           b                               \                    H                       2                                                    j           n                                                               3           X       b

                            H                                           t                                                                                                   "           8                                                                                                         K                                                               D           w

                            3           UNIX                                    +                                                               5                                                                                                H                standerd input                                                                          C

    Hstandard output                                                                                b                                                       b           X                       \destination"                                                                                             2                       f           A           1       G               1

\cp le1 le2"                                        9                                           le1                             X                   \source"                                                                                                 le2                      X                               \destination"
2



                        b               9                                                           \     "                     2                                   &                       1        9                                           b                \   /                                                                   2           "           f           A       G

1               ls      9                                                                           \ls" \ls                T                                           (                       "                            |       :                                                                        #                       3                   K                               K

                                            H                                       \       /                                                           2       "
                I       5                   UNIX                                                                                        2                               |                                                        ?                                                                                2               3           UNIX                                    &

                    \                           0       '           " redirect                                                                  A                                               ls                                                                                                                                    j           n       (

            K                       A                                   .                                               D           R                           w                                            j       n                                                                \               0           '       "
                            K                                   3       J                                                                           j       n                                                            \           0    "      '                                            j       n                                   0           '                                       \
t   "   9                       r                       W                       A                               .       \ls -la"                                                            D                                        \list"                           j           n



% ls -la > list


9   `               3               K                         \ls -la"
                                                                :                                                                                                                                        .                                               B                w                   \list"                  9               j           n                                   A

                                    \   !               " append                                                        j           n                   J                           \       t        t           "
% ls -la >> list


9   `               3               K                           :                       \ls -la"                                                                                                                                                             \list"               9                   j           n                                           A                   \list"
                            B       D       3                   j       n               \ls -la"                                                                    !                       3        \list"                      b       /                                                            A                   \list"                                              D       3

J




cat                                     9                                                   \ "                                                                                     catenate    concatenate                  T                                                                                                                    )       (                   L

                                        .                                   R                       =           #           R                                                           X  \cat le1 le2"
                                                                                                                                                                                                 |                                                                                                    .                   le1 le2                                 =           #       R

                                                                            #   R                   |                                                                                                                    K                           .                9                                           b       \ " /                                           2       {
                                                                            K




                                                    X       |                                       \cat le1 le2"                                                               9                                                                :                9                               j           n       =       #       R

                                        3                   K                       A                                                                                                                    W                       j           n                J           m                                                           3                   K

                                                    \           0       "       j           n



                                        % cat file1 file2 > file3
                                          8  y   DOS   copy file1+file2 file3


                                                                            |                   \cat"                                       j           n                   A       \cat le1"                                            9                                                                        3           DOS                     9                           \type
                                                le1"                                                        ?                                                   T                   G       \            1                               0           '       "                                    9                                                       |       1           b
                                                                                6
                                                                                                                % cat file1 > file2
                                                                                    y                           % cp file1 file2


                                                    3                           UNIX                                                                    SunOS \cat"                                                                                               j           n           /                                           r                                               \-n"
                                        9                           4           A           |                   9


    6           G                       B               3           unix                t       &       n                           b               !           ]                                    W       !                                                                                                                            C                           t                       ]




                                                                                                                                                                                                20
Chapter 2.   +           UNIX                                                                                                                                                                                                            2.2.                                    .




             % cat -n file1 > file1-with-line-numbers


                             le1     9                   j           n           n   N                       Z           C       t                                                               r       D                      \1"           \2"
                             h   v       .                   Q                               9                                               r               /                           w               (               \ le1-with-line-numbers"
                     j   n




                     9                               r                                       @                           |                   \nl"        9



             % nl -ba file1 > file1-with-line-numbers


                             \cat"                               t           m                                               9



             % cat file1 file2 > file1
             % cat file1 file2 > file2


             |                                               1                                                                                           le1                         /                       le1             3                   t                                   le2
                         @        \cat le2 >> le1"                                                                                                   |                                                 \cat le1 le2 > le1"
                         \cat le2 > le1"                                                                     !       P                                           G           >                   \cat: input le1 is output"
                         %                     \ "   .                                                               t                               0                                                   j       n       `               y                               @

             j       n           n \ "   D           w           t                       G                                                                                               X       |       3       \cat le1 le2"                           9                           ^

             b       s       G \ "              \ le1"
                                                 t                                               j       n                                                               5                                   J               \       W                   =       #                   j

             n             le2              le1 "
                                             .                               w



                                 \cat le1 le2 > le2"                                                                                                                 !                                           3       \cat"       ^   s                               G           le2
                                     *



                     3           \               0       "   `                           0




man              9                       \manual"                                                                                                                            :                                                                   A                   \man ls"
                     :   \ls"                                                                        &                   \                       \man"                           9                                                               v

                         ^   b                       {       N                       UNIX                                                    i       e                                                                                                           B           &

                     1   D               j           n                   B                                       M                   T                               B                                           $                                                                   |

                     :   :   9           j           n                   `                                       9                   j       n

             K                                            \  ^           b                               `           ]                   K       "       9



                         /               :           \man"                                                                           |               \man -k                                 n       "       C       "           0       \   n       "       C       "   b   n
                     7

                         A                                               b                           \copy"                          b       n



             % man -k copy
             ttcp (1) - copy files in a ToolTalk-safe way.
             bstring, bcopy, bcmp, bzero, ffs (3) - bit and byte string operations
             copy_home (8) - fetch default startup files for new home directories
             cp (1) - copy files
             ......
             ......
             cpio (1) - copy file archives in and out
             dd (1) - convert and copy files with various data formats
             pg (1V) - page through a file on a soft-copy terminal
             rcp (1C) - remote file copy
             tcopy (1) - copy a magnetic tape
  7b         b                   \man -k"                        8                                       \apropos"

                                                                                                                                         21
2.2.    .                                                        Chapter 2.   +       UNIX

       uucp, uulog, uuname (1C)    - system to system copy
       uuto, uupick (1C) - public system-to-system file copy
       ......
       ......



            :   :   9               t   \        n   "   C   b       n            r   /      C

              manpage        section \-"
                                y                                \



         manpage manual page                                 S       S   &                       j   n   |

       tro /nro         +   W           9




       .\" @(#)cd.1 1.9 90/02/15 SMI from UCB 4.1
       .TH CD 1 "9 September 1987"
       .SH NAME
       cd \- change working directory
       .SH SYNOPSIS
       .B cd

       .I directory
       ]
       .SH DESCRIPTION
       .IX cd "" "\fLcd\fP \(em change directory"
       .IX "file system" "cd command" "" "\fLcd\fP \(em change directory"
       .IX "working directory" "cd command" "" "\fLcd\fP \(em change directory"
       .IX change "working directory"
       .IX change "directory"
       .IX directory "change working"
       .I directory
       becomes the new working directory. The process must
       have execute (search) permission in
       .IR directory .
       If
       .B cd
       is used without arguments, it returns you
       to your login directory.
       .\".LP
       .\"Because a new process is created to execute each command,
       .\".B cd
       .\"would be ineffective if it were written as a normal command. It is therefore
       .\"recognized and executed by the shells.
       In
       .BR csh (1)
       you may specify a list of directories in which
       .I directory
       is to be sought as a subdirectory if it is not a subdirectory of the
       current directory see the description of the
       .B cdpath
       variable in
       .BR csh (1).
       .SH "SEE ALSO"
       .BR csh (1),
       .BR pwd (1),
       .BR sh (1)

                                            22
Chapter 2.   +            UNIX                                                                                                                                                                                                                                                            2.2.                                             .




                      9                   j                                                      \cd"                                                         manpage                                                     D           3       j           n                                                                       3   |

             a                                                                                \man cd"                        `                                                   0                       9                       j                   Q                                        \nro "                             9            P

                                                                  W                       3                   K           :                                               9                                               %                               3                                   \man"                               `

                      : \Reformatting page. Wait..."                                                                                                                  C                                   Q                                                   /



                 9     manpage                                                    D           w                       H                                                           v                                   !                               !                       &                   1                                   y        !

                 \section"           UNIX    manpage          F                                                                                                                                                   5           v                   |                       8                       sections
                 1.
                 2.                                         System Calls
                 3.           P           0               Library Functions
                 4.           \                   H       C                   ,                               P

                 5.   j       n           }       P

                 6.           Y                   P               Games!!
                 7.
                 8.                                               X           m




                                  &                           \man -k copy"                                                                                       s                   \pg"                                            \copy"                              9                    C                      b       n                ?

                                  :           :                     \man 1v pg"
                                                                          9                                                       9           `                                                                                                                                                                                                9

                   \man"
                      3        \1v"                     section 1 \pg"                                                                                                    :                                                                                                                                                   %

                section                                       manpage .                                   !                                       (                                           b           ?                                                                                                                           3    ^   b

                  section                         section         `   section 1                                                       Q                                                                                                                                               0                                                    .

                      D       w                                              \man                                     2       ]                       X       |           3                                                                                           &                               K                                        (

               "            section   K                                       \man 1                                                      |                                       9                                                       :           :                               &                   %

             time" \man 2 time" \man 3 time" \man time" \man 1" \man p" \man
             man"              \man core" \man 5 core"        |           f                                                                                                                                   :       :                                           >                   -




                                            \man -k"                                                  P                                                                                                       9                                                                                    v                      9                    G

             >   \/usr/man/whatis: No such le or directory"                                                                                                                                                                                                           .                                   X

                 ^        \whatis database"
                          b       X                                    \makewhatis"
                 \mkwhatis"
                 T                                                                SA              T                                                                                               .                                   P                   A                                                       |

                 :    :       %                   2       ]




setenv       9                                        set environment                                                                                                     '                                                       (                                           b           n                                   3       C Shell
                 a                        1                       9




set          9                                        setenv                              b                   5   8                                                       '                           Shell                                                                                        !

                 3                        a                \.cshrc" \.login"                                                                              9                   j           n       `




stty         9                                t                                           '                                                                       C   -               3       "               8                                               L                               A                                                '

                 \Control-H" \erase"                                          W                                                                                                           1                       \Control-H"                                                     `                                                       \back
             space"(      )                           "



             % stty erase ^H
             % stty -a
              ........
             erase kill    werase                                                                                     susp                            intr                        stop                                        eof
              ^H     ^U     ^W                                                                                         ^Z                              ^C                         ^S/^Q                                       ^D


                                                                                                  G               '                                           |               :           :           b                                           m                                   ?                               t

                                                              '                       :                       \stop"                          '                                                                   K                                                                   9                       .                            T

                 \Control-S"                                                          K                                       |                           ^                   @                                                                   \Control-Q"                                                         ?




                                                                                                                                                  23
2.2.                .                                                                                                                                                                          Chapter 2.                                       +                   UNIX

lpr             9           line printer                                                                                                   \               |       G                                   ^                   ^    b               3                   M               K                                           R

                                     line printer                                                                                      9                                               (                                                    *                                           ]           P                       \lpr
                -Plp1 le1"         \lp1"                                                                                   ^       (                                                                                                                                                (       C                               L   3

                /etc/printcap                                9           j       n                                 b                                                           |
                                                                                                                                                                                                                       8        A                                                   b                                       I

                        ^                                T           E       (       C             |                               j           n                           K       G                                       I                    ^                   4               j                               A

                                                                                          ^    (                                           3



                                                 A                                        ^        (                                                                       1                                   ^           (                        /                                   \lp"                        b

                            B                                    ^           (       W    \lp"                                                                     \lpr le1" \lpr -Plp le1"
                                                                 ^   (               `




lpq/lprm        A                                                3                   ^                                                                     :       :                                                                                        9       b       ^       b           3                               |

                        \lpq"        9                                                                                                                                                                 D    (job number)
                        i   r            A                                                                     J                   \lprm                                                       D           " \        "                             D                                               lpq                         :

                                job number 9
                        9


                % lpr curves.ps
                % lpq
                Rank   Owner      Job Files                                                                                                                                                                                    Total Size
                1st    john       213 curves.ps                                                                                                                                                                                176320 bytes
                % lprm 213
                Bart: dfA660roland dequeued


mv              9                              move                                                    )           (                   L                                                           j       n                                                            A                               j       n               le1
                                             ABC
                % mv file1 ABC
                  ABC     B D 3                                                           (




                A                            ABC                                          D    3                                                                                           b                   !                                                            1           \   .           j       n               le1
                        W                        ( ABC" le1
                                                         C                                                                                                                             W                                       ABC                          j       n                           9

                DOS                          rename     \mv                                                                    j           (                       j       (       "                                                A                       ABC                                                     B       D   3

                        j   n            J     ABC                                        *                                                                                        G       1                       \cp -i"                                                                       \mv"                           `

                            T                           \-i"
                                                         W           Y                                                 9                               4               \mv -i                                  j           (                j           (       "           0                   \     "     j           (       \

                        D   3    `                       |                                                                                                                                 .                           j       n




rm              9               remove                                               )    (                L                                               .       j       n       z       t           *                        A


                % rm file1 file2 file3


                        .        le1                         le2                         le3       9                               j           n           l       *        DOS    3                                                                del             9                                               z       t   j

                n                        0                                               UNIX                                                      ^           b       undelete                                9           /                                                j       n                                       l   *

                                 =               /                                   W    l    j           n                   G                       0



                            \mv -i" \cp -i"                                                                                                    3               l       j       n           G                   &                                            UNIX                                                &

                g           \rm -i le1 le2 le3" \i"                                                                                    9                               4                   \inquery"                                                                                                                            b

                        1     \interactive"                                                                                                                                                ?                   E                        /                           A       h                                                   3

                        W   l    N               j       n           G       K                                                     g                       @       -                                                                    /                   \y" yes
                                 l       *               j       n                             |           /                   \n"                             T                   RETURN                          "                    D           C
                                                                                                                                                                                                                                                            10
  8   BSD           unix     SunOS   A                                   b       9        j    n            System V                                                          unix                         A           HP-UX                        b                           ]                       L       printer
  9A                   System V                                              unix                          HP-UX                                               J           \lp"                                        \lpstat"                                                         ^

 \cancel            D "
 10         G   3    \cp -i"                 I       5                   9                     !




                                                                                                                                       24
Chapter 2.                              +                   UNIX                                                                                                                                                                                                                                                                                       2.3.       j   n   J




                                                    8       E       y       \-i"                9                            4                                       \-f"                9                                   4                                                                   \force"                                                   l

                                                                                                                                                                                                             9                                       4           l       J                                           &

                                                                                        A                       9                                4                       R                                                                                                                                                                                        b

                                                                    SunOS                                   |           \-i"             8                                   b                                                           HP-UX                                   J       |           \-f"                    8
                                                                                                                                                                                                                                                                                                                                                  11

                                                                                                                             4               \-R"                                3                                           UNIX                                                                                |                                             \-r"           \R"
                                                \Recursively"                                                                                                                                                            ?                                           l                                                   b       9        K                               9

                                                3          MS-DOS                                                                                                \deltree"                                           9                                                           A         \rm -Rf junk"                                                              \junk"
                                        9                                   |                   X           b                                                        j           n                                                                       K           l       *           = \junk"
                                                    .               b       \f"                     4                    X       |                                                                   t                           j       n               b               P               permission                                                        1                   l

                                                0




mkdir                                   make directory                                                                   !                       DOS                                                         T                                                                                           C

                                        A  \mkdir dir ABC"                                                                                           3                       G                                   5                                                                   \dir ABC"
rmdir                                   remove directory     DOS                                                             !                                                                                                                                                       z           t                                                     (

                                             \rmdir dir ABC"
                                                    A                                                                                                                                    G                       5                                   \dir ABC"                                       9                                    z       t        *      A

                                                                                                                                 1                               b                                   j           n               T                       b                                                                                            \Directory not
                                        empty"                                  G           >                                                                                                                                b                                           3                                                    ^           J       *        G              l    *

                                        9




mail                                    9                                                                           T                        P                       A                                                       B           .           *                                       ?                           '        j           (                \letter"
                                                                                                                                             2                                           somebody@somewhere                                                                                                      J                    |                        mail some-
                                        body@somewhere < letter                                                                                                      t               h                                                                                                                                       mail                 9               P

                                        s                                                       .                                                        A                                           (                                                                           P       ?
                                                                                                                                                                                                                                                                                                         12

exit                                    9                                                           @                   shell                                                            A                                                   B               3       t                                       shell                                     9

                                        logout                          b       !




2.3                     j       n           J




            1                                                           G                                                            b           n           j           n                                   F                       j           n           J               ( le permission)
        G                                               UNIX                            N                                                        |           3                                                                                                                                       j       n                                                            UNIX
            b                       9                   3                                       UNIX                                     %                                       h           v                                   j           n                                           B           *                                    A                                    j

n   A                                                                   l           *                                                                *                       A                                                                                                   :                                                                                        j    A

                                                                                                                    X    9                                                       UNIX                                            ]                                                                                       N                j       n                       K

                    x                       (           C                           v                   O                                x                                                                                       z                                       |       \                                   |                                            |

            E       j       n                                   J                                   w                                                                                            P



                                \ls -l"                                             :       j           n           `                                            v                                               Z           C



drwxr-xrw- 1 john project1 128 Apr 4 12:19                                                                                                                                                                                           dir
-rw-r--r-- 1 john project1 545 Apr 14 12:19                                                                                                                                                                                          file1
----r--rwx 1 john project1 124 Jan 13 09:01                                                                                                                                                                                          file2
lrwxrwxrwx 1 john project1   6 Jul 22 09:22                                                                                                                                                                                          file3 -> file4
-rw------- 1 john project1 212 Jul 22 14:23                                                                                                                                                                                          file4
         .................................
    11                          1       /                       b                   9                                                        p
    12 b        n                               C                                                                                    G                                       0       a                   T                                               Z




                                                                                                                                                                                                 25
2.3.            j       n       J                                                                                                                                                                                                                                                   Chapter 2.                                                  +                           UNIX

                \                   R                       &                                           g                                   j           n           T                                           D                   J                               =                                                       T                                                                           j       n

            =           b                           =           b                   X                               group                           (                       j           n                                       |               Byte                                                                                    j           n                                                           ^

`                       t               \                                           j       n                   T                                           (           C



        j           n               T                                                   D                   J                                                                               5                                                   4                   1 3 3 3 m               m                   m                                                   g                       j       n       l       V           1
4                       j       n       =               b                               user                        E           h           j       n                           J                               3   4                                           j           n           =           b                       !                   N                                       group                           E   h

j   n                   J                               3       4                                                                       others                                      E           h           j       n                       J                           3       4                                                           j           n                   J               b

\   (readable)                                                                  (writable)                                                                              (excutable)                                                         |                                               le1
-rw-r--r-- 1 john project1 545 Apr 14 12:19                                                                                                                                                                                                     file1
^^^^^^^^^^


            4                   j           n           l           V                                               1                               t                           :                               l           V           b                                                               j           n                       |       \-"                                                                     j

n                                                   |           \d"                                                                                     directory                                                           =                           |        \l"                                                            =                     link
        #                           \rw-r--r--"                                                 |                                                                        3 3 3      m               m                                   G                    \rw-"                                                          9                               C           -           character
    =       b                                       E           h           j       n               J                                                       \           (readable)                                                                      (writable)                                                      &                               j           n       (-)
                                                            \r--"                           9                               C           -                                               j       n           =       b                       !           group                                                               E           h       j               n               J                               \




                                                \r--"                                   9                           C           -                                                           !                                               E       h       j           n                       J                                                           \




                            9                   j           n           J                       !       P                       J                           UNIX j                                              n                                                   b           f                                                       N                                                       j       n

                                        1                                   G                                                   group                          UNIX                                                                                                                                 5           v                       ]                                                                                   L

W   !                                       group                                       Q               9                       !                                   group                                                                       |                               j           n       J                                                                                   j       n

    l       y                           8                                           :               T                                                                                   X       |                                                   g       :                       \Permission denied"                                                                                 9               G       >       `

                                        %                                   .



        3                           a           &                       1                           group                                                                                                                                                                                                           P                                                       group                                           @

                                A                   .               &                                                                       group                                                                       M                                       |                                   "           `           ?                                                 group                             +

                group \ "
        ?                                       3                               |                                                                                                                       le2                         J                           %                                               b                                                       9                       j       n       J           )




        #                           :


drwxr-xrw- 1 john project1 128 Apr                                                                                                                                                              4 12:19                                         dir


                                    C           -           \d"                                                                                                                                     J                               5                   G                   1                       K                                                       b                   F

            \                       "       J                                           4               A                                               '                       \                                                   "                                   9                                                           \                                               "                           1

|                                                                                   \dir"               9                                                           J                                   \rwxr-xrw-"                                                                                 &                       3       G                       X           .                                               9

                        =       b                                   \                                                                               9                                                           E                                                               1                       X                               \                                       "                                   \
    "               X       |                   9                                                                           9                                                           =       b                               !                   group                                                   K                       |                                   9                               /

                                                                    4       Q       \                                   J                       "               I           5                       '          \                        \                                           "                           .                               \                                           "           X       |

1           9                                                       E           \                               "               w                                   &           !                           group                                           A                                   \cd dir"                                                                                    \permission
denied"                             /



                    y       {       b           j           n                   J                           j           n           =       b                                                           Q                   |                   J                                                                                               j               n               J

    +                                                           chmod
        t                           :           j           n           l       V               \   =                       " link
                                                                                                                                                                                                                    26
Chapter 2.              +                UNIX                                                                                                                                                                                                                                                            2.4.                    #




lrwxrwxrwx 1 john project1   6 Jul 22 09:22                                                                                                                                          file3 -> file4
-rw------- 1 john project1 212 Jul 22 14:23                                                                                                                                          file4


:                           le3                                   j       n           l       V                       \l"                                                                    =                               j       n                                                           \               T       "
         /          3         le4                                         le3                             J                                    \rwxrwxrwx"                                                                           X           b                   K               \               \

    "                           :    :    \               T       "                                                                        /         le4                                     Q                           b           =           b                                   \               \

         "     9                :                                     !       8                                                            b           F                     M                       T                   J                               G                   \rwxrwxrwx"
                            J                 :           \           T       "                                            j           n                   %                                                             le3                         J                       @           j               T                                   le4
             \-rw-------"


2.4             #




             UNIX                             .




chmod                               change mode                                                                                                                 j       n            J                               |       G                               le1                                     u                                   W

                        b                         |           \                                                                                            !            group                                                                                    \                                                               |



                        % chmod 600 file1


                        9                                             600                         N                                    C           &                        =    b                               6                       !               group                                                   0
                                0             J



                                j    n    =           b                           J                               \6"                                  %                                                 9                           C                      2                                                                        610 =
                        1102               \1"                                    J                                          \0"                                            J                        n           T               X           |           1102                                                \ " \               J

                                         \ "                          J                                                    \ "                                      J                    n       T                                                       \rw-"
                                !        group                                                                         J                   K                   010 = 0002                                                            \                                                                   J                   K           n       T

                                ---                       !                           A                               \r--"                                    100 2(= 410)                                               \                                                                                                          \rwx"
                                  111 2 (= 710)                                                       \                                                                                  X           |                                       3           T                                   A               .                   j       n

                        W       \rwxr-xr--"                                                                                            |                   !                     ]                                                                                               J                                               B               =

                                     j    n       3                           J                   `                                                F            A        G



                        lrwxrwxrwx 1 john project1   6 Jul 22 09:22                                                                                                                                                                      file3 -> file4
                        -rw------- 1 john project1 212 Jul 22 14:23                                                                                                                                                                      file4


                        A                 E                   le3                             J                                    @                                                                     le4                                                             %



                                          |                   -       0                   j       n                                                                         J                                    Y                                                       j       n           J               E

                                (



                                          |                           .                                                            W       \d-wx------"                                                  Q               \ls                                                         (                   "           :

                                                              \cd                                             (            "                                                                                         \cd ./                                                  (                   "
                        :       :    &                                %                                                                                                  J                       :           :                                               A
                                                                                                                                                                                                                                                                                 13

                                          j       n           J                           t                                    C                                            |            Z       C                                                                       A                                           le1             W       \   !

                        group                                                 |                   (writable)"                                                       |



                        % chmod g+w file1
    13                                                            >                                               9        :                   m       P                                 G       >           .           .                   unix                        ?           l




                                                                                                                                                               27
2.4.      #                                                                                                                                                                                                                 Chapter 2.                                       +                       UNIX

                          \g"    group \ " \ " \w" \ "           \        "                    m                                                                                                                                        J                            j       n           =       b                                       r               \u"
                            user \ group      "    \g" group \     " \o" others
                                                                   !                                                                               r                                                                                                                                                                                                     \   X

                          b      "      \a" all \ "           \ " \ "          r                                                                                                                           J                                        m        r                           n       T                           J                             \
                            " \ " r            \ "    '                                            J                                       u               r



                          %   chmod                       o-w file1    n T                                                                                                                             J

                          %   chmod                       a-rw file2   n T                                                                     X       b                                           \                                        J

                          %   chmod                       g+xw dir1                                                                            !           group                                                                                                 J

                          %   chmod                       u=rx file3   '                                                                       j       n       =           b   file3                           E                                             \

                          %   chmod                       u=rw,go=r file4                                                                                          chmod 644 file4


                                                                                               \ "     u               r       `                                       (                   '                        E                               A                                        \u=rx"                                      E       \   j       n

                          =   b           "                   J           \rx"                                                                                 \               \                                            "               ^       b        \w"                                \                                        "           &       '

                              E                               group others                                                             J                                       (                                            %                   J                                                                    t

                              1                                |           !           `       E                               |                           E                               J                                ?                                                                            \go" \group"
                              \others"                        )        3                   R



                              chmod                                b                                                                               option \-R"                                                                                                                           \R"                                     G                   3       1

                              \rm -R"                                          !                                                                                                               9                    X           b           j       n                                                                                                ?       J

                                                              A



                          % chmod -R ug+r,o-r,a+x dir1


                                      |                       1




which                                 0                                                    X           3                   H               B                   B                                                                                UNIX                                                 \               "               @                       9

                                      5                                P                                           A                       0               \cat"                   9                                X           3                        H                                       |



                          % which cat
                          /bin/cat


                                                                           cat             X           3                           5                   .           /bin/cat
                                                                           A                                                   0                           j           n           3                           2    ]   \which"                                          9                                           ^           9                           \

                                              A                            3           |       G               _                                               j           n                                       \my letter"                                                       3                       Y       3

                                          0                                                                J                   j       n                               b       A           !       !                                                                         0           R

                                                      2       \cd"                                                 \ls"            :       :       \my letter"                                             3            3                   \                        3

                          0           UNIX                     b                                       ]                               Q                           9                                                                                    \ nd"                                                                                                0

                                                                       \which my letter"                                                                               0                                                                .                                    -           \                           "   j                           v

                          3                                            2           ]       0



                              which                                                                                \.cshrc"                        j                               v                                            0           J                        permission                                                  \                               "
                              j       n               0                5




                      1                                           \which"                                                                  b           ^       b           3                           \.cshrc"                                                          L                   (               alias
                      2                                                    3               \.cshrc"                                            X                               path                    5                    0                            0
                                                                                                                                                                                                                                                                                                                     14

                              f       A   1           G                                                                               \cat"                                                                                                     \cat"                9                                           9               3           J               j

                          n                                                        X       |                               \which cat"                                                 0                                3           /                                G                                                   j


  14   path           (           alias           3           C Shell                                          a                           1                       A                       T                                                                             %                                   |                                           :
                  B       /           9                   .   \which"                          9                               :                       T                                               |       {                            :                                    z                       K                                   3   \               C
Shell         a                   /       :       9




                                                                                                                                                                   28
Chapter 2.   +           UNIX                                                                                                                                                                                                                                                                                   2.4.                         #




                                     \.cshrc"         :     \cat"
                                                              :       3                                                                                            b           ^       b       .                                   9                       C                        L       W                       (                   b

                          #    \cat:
                                  /          aliased to       1    "                 \cat"    ;               ;       ;           ;                                                        %                   %                                                                        1                                               @    j

                     (           \cat XYZ"                        \              XYZ"                                                 `                                        @       j                                                           %                   %                                                                .           3

               \.cshrc"                  \cat"                    L                                                                                                    (



                 A        \.cshrc"
                          3                             \cat"                              \.cshrc"               ^       b                           L                                                                                (                                                                    .                   3

                         \path"
                              L                                                           5                                                                                                                                                                                     0               :           :           b           ^       b

               \cat"                  j           n\       "              v                                       j       n           J                                                                                0

                                              3            \       " \cat"        5                           s                   b                       j    n           J                                                                                                        j       n                       0

             X   b                5   \cat"   K       ^           \cat"
                                                                      0                                                                           j       n                T                   b       0                                                                    j       n                                                   j    n      J

                 \       "                           \no cat in xxxx yyy zzz : : : "          \xxxx                               /

             yyy zzz "      \.cshrc"             path 3                           \cat"                                               L                                                                                                        ^           b       0



               which                                                         \cat .cshrc"
                                                                                  @               -           X                                                                                @       P           0                                   A

                 |          \.cshrc"                  .                                                           /                                                                                                                                        9                        T                                                               M   M

                                                  \which cat"         H   \cat"                                                           |                                                                                    @           -

                    \cat" /bin/cat                    \cat"                                   \cat"                                                           (                                                                                        T           3                                5

                     P



                          |                           :               3                                   \.cshrc"                                                                 9



             alias cat ls


             D   ?   j    n               Q                           \which cat"                                                 :           :                                            G                   ^                   9                                   `    b                           !                                       .   9

                     W



             alias cat ls -la


             D   ?   j    n                   Q                       \which cat"                                                 :           :                                    b                               !                   #                                .       9                                                           \.cshrc"
                 J   *            D       ?           j       n                           #



             % alias cat ls    T

             % alias cat ls -la


             Q            \which cat"                                     :           :                               b                                   !                        E                   G                   1                       b           n       \which"                                                                          |

             1            %               9                   :               8                                                                                    Q                   !




vi           visual editor                                                                            9                                                                                                            _                                               Editor                                       &                   ^        b

             UNIX                     .                                       K                                       Well                            A                                                                    UNIX                                        .                                                y                               K

                 \vi"                                                                                                                                         &                                                                                        \vi"                             UNIX
                 default                          _                                                                                                                                                            ]           P                       |                                                .                       a       "               ^

             X   |   3    9                                                                   M           +                                                            Q                                       &                                           _                j       n                                                   b

                                                                              ?           ]               -                   _                                    |                                                                                           vi15
ps           process status                                                                                                   :                       G                                            3                                           P           b                                                        G                   1

             UNIX                 9                   9                                                                                   3                                                UNIX                                                                !       `                                                                3

                 P            UNIX                                        9                                            \ps"                                                :       :                                           G                                                                                3           UNIX
                          P               &                   b       `                                                   \                                    " process
                 \ps"                                                             4           b               4                                               a u x w
             % ps -auxww
 15 E    .                T               T               1                                                                                                                        .               t       &                                   W




                                                                                                                                                          29
2.4.         #                                                                                                                                                                                                                     Chapter 2.                                  +                   UNIX

                       \a"(all)                                    .                                                                                                           \u"(user)                                                                                &                                                       \x"
                           .           ^   b                           ^                   #                                                                                        \w"(wide)                                                          9                           4       J           |        .

                                                                                       A                                           9                           4               .                       K                            b                                                                   6       *                    K

                                       I   5               b           `                           :                                               3           e                                                   P                   %                           \w"                                  9
                                           16              9                                                                   G           >                                           9



                       USER                                         PID %CPU %MEM                                                                      SZ                  RSS                 TT                  STAT                        START TIME COMMAND
                       root                                           0 0.0 0.0                                                                         0                    0                 ?                   D                           May 10 1:03 swapper
                       jacky                                       7559 0.0 0.0                                                                        36                    0                 co                  IW                          May 23 0:00 /bin/sh ..
                       john                                        1345 35.6 4.5                                                                       52                    0                 ?                   R                           May 24 12:45 /usr/local/


                       A                           \x"                     4                                                                               \root"                  X           =           b                                                                                                A                       \a"
                       4               J                                                                                               A                       \w"                                         4                                                                                           \jacky"              9

                               X       =   b                                    7559                                   :                                       9               3                                                    P                  .                J                                       H                         ^

                                                           A                       \u"                                         4                                                                                                   t                   \                                                                9

                                       |                   4                   process id PID                                                                                                  4                                                   X                                       CPU          f                                 4

                                                   X                                                           B       7                   f                           t                                                           4                   A                       b                                            \man ps"

                                                                   t                           \ps"                            :                                       *                                   P                \                              _       r        " PID
                       1     \kill"                                            l       *                                                       b       `                                                                   \ps"                            :                                                R               ^

                           \%CPU"                                                          :                                                                   CPU                 t           9           `                  \ps"                                             K                                        |   .       4

                       G   0      \-"      r                       6



                               9                                       +                                           UNIX                                    X                                                           process                                                                                  P           R

                                                                               N                                                                               K                                       _           r                           P                                                                            @

                               1                           \ps"                                                        :                                               UNIX                                                            b                   9   \                               "                                     ^

                       3                                               n       ^                   c                   9                                               ,       J                       UNIX                                                                                W

                       login                                                           s     mail                                                                                      9                                                               G                                               Q                    I   5    `

                               3       !   C       o           s                           idle                                                    9                   b                                           M                   (       C                   \   1       ~           " daemon                                  9

                       (       C                               b                   9       F       1                       W       1                                               MULTICS17                                                                   b                   1         \Die And Execute
                       MONitor"                                                                                                                                                                                                                        UNIX                        Z



                                       b           3                                                                   UNIX                   \ps"                                                 4           -                                               3            System V                                                UNIX
                                                   \ef"                                                                1                   \aux"
kill                   9                                                                                           3                                                       process                                         l       *                   f       A                                                P           E   Q    s

                                                           ]                                                                                                   T                                                                                           P   .                                   .            *               9    `

                                       |   \ps"                                            0                                           P                                   _       r (PID)                                         Q                   l       *                           |   G                                     1

                                       \jacky"                     9                                                                                   *           _       r       \7559"
                       % kill 7559


                       9                   \7559"                                                      l           *                       process                                         0                                   E                           J                               0       l    ?                                 Q

                                                                                                   l                                                                                                   b           `                                                       \kill                            _    "  r           ^

                       l       *                                       9                                                   P                           #                   #                   \               l                   "                                                   |                    \kill -9                      _

                       r   "                           l           *                           u           9                                                                       ^                                                       0




grep                   9                                                                               &                   b                                                                                           .                   E       X                   \regular expression"                                               !

                                       X   |       9                                           +                               t
                                                                                                                                                                                           18                                                                              C




  16 9       E    SunOS                                                unix                                            b                           4                       A               HP-UX                                                   \ps -ef"
  17 n   y       MULTICS                       :                       a
  18               3       0       a       +




                                                                                                                                                                   30
Chapter 2.   +             UNIX                                                                                                                                                                                                                                           2.4.                   #




             (1)               3       j           n                   0                                           n       "       C


                               %       grep                        "printf" file1
                               %       grep                        "My" file1 file2 file3
                               %       grep                        -i "My" file1 file2 file3
                               %       grep                        -n "My" file1 file2 file3
                               %       grep                        -v "My" file1 file2 file3

                                                                               1                       3                       G       9                                               j           n               le1                              0                b    \printf"               9       C

                                                                                       .                                           J



                                                                                               1                       3                   G           9                                               j       n                   le1                      le2            le3                       0

                                       b           \My"                9               C                                                                                   .                               J                                                                 `

                                                                   3                       j           n                                                                                                                                                         E

                                       \My" \MY" \mY" \my"                                                                                                             K                   0



                                                                                                                                                                                                       .               r



                                                   "                                                                                           8           D                                           \                       My"                  9       C



                                                           |                           \i"\n"\v"                                                   )                           grep                            A


                               % grep -in "My" file1

             (2)               3                   9           process                                             0


                               % ps -auxww | grep textedit



                               9                                           1                           G           3                                       X       b               process                                         0                    b       \textedit"               9           C

                                                               process \|"                                             3           UNIX                                                                                                    F                            pipe                             3

                                           4           a           b                                   +




df           disk free                                                             9                                                                                                                           ^                       b        n           j        n

                       |                                                                                                                   X                                                                       j           n                                                                 =   b

             {    /dev/sd0                                                                 5               W                               j           n                       ( / /usr /spare)                                                                  b               j           n               (
             /home/tool /home/cadence)                                                                                                         J                                       ^                           j           n                        \ "(mount)
                                                                                                                                                                                                                                                        ,

             &         j           n                                               C                                                               K



             % df
             Filesystem                                                                                                kbytes                                    used                           avail capacity                                                   Mounted on
             /dev/sd0a                                                                                                  28703                                    4295                           21538    17%                                                     /
             /dev/sd0g                                                                                                 215195                                  162776                           30900    84%                                                     /usr
             /dev/sd0h                                                                                                 499710                                  337437                          112302    75%                                                     /spare
             roxy:/export/tools
                                   950755 595358                                                                                                                                               260321                                          70%               /home/tools
             dylan:/export/cadence
                                  1363950 1081046                                                                                                                                              146509                                          88%               /home/cadence


                                                                                                   j           n                                   @           j                   H                           A                 \/dev/sd0a"                                                             9

                   j       n                                       ^                                           X           =       b                       _       r               \0"                                    \a"                           s                                                b

             `         |                       5                           partition                                                                           s                                                       \roxy:/export/tools"                                                          9

             j     n                                      \roxy"   ^                                           X           b                                                           9           I       ^                          \NFS"
             ^                     \ "     :             \roxy"                9                           j           n                               3                           9           I       ^                    \/export/tools"                                                          3

             X                         9        \/home/tools"
                                                   I           ^                   Q                                                                                                                   (       C                       !                    @        j               !

                                       \/home/tools"
                                               D                                                                                                                               `                               3           e       2                                     \roxy"          9       I   ^




                                                                                                                                                           31
2.4.     #                                                                                                                                                                        Chapter 2.                                          +                       UNIX

                 \/export/tools"                                                                                                          9                                   K                                               i                               9                \NFS"               ?




                                                      j       n                                       b           9           K       \kbytes"                                                                                                                                     j       n

             B                *               used                    9   K                                                                           j   n                                       y       9       K                                                                "

             j   n                                                        0                                                   j       n                           \ "     ,           3                   X                                           9                                                    5




                     J                                                                                                                                                                                    \used" \avail"              m                                                                    y

                                                                      9               .                                                               I   5                                   V             10%                                       1               R

                 H            b                                                           |                                                                                       P                                                   9                               1                    I   5           X

             |           g                                    s                                   j    n                                \capacity"                                            4           &       Q                                       100%                 `                           H

                 #                    A                       s                                   '               s                   \File system full"                                                          G           >           `                           T

                                  :                                               \ "
                           System V                                                                   UNIX    \df"                                                                                            }           P           }           b                   !                            b

                         \bdf"      \b"                                                                \BSD" \Berkeley"               T                                                                                                   }           P                                    X   1




du           disk usage                                                                                                                                           |                                                                                                       \/usr/bin"               9

                                                  7324 KBytes
             % du -s /usr/bin
             7324    /usr/bin


             A                    N                                       X                                                                                                                                   |                                   \-s"                     4



             % du /usr/bin
             1500    /usr/bin/sunview1
             7324    /usr/bin


                                                                              3           \/usr/bin"                                      9                   b                                       \sunview1"                                                      9

             1500 KBytes                          t                                                                                           \/usr/bin"                              9                                                                       |                    X       b   j   n

                                                                              7324 KBytes                                                              \-s"       b                                           4           `           :



                              b                                                                   C                                   |       \block" 512-byte                                                                                            \block"
                     |   \man du"                         :       :                                                   |           %                           3




telnet       9                                                                                =       a                               A                                       roxy                    9               ^                       =           a                                |

             hostname                         T                                       IP address                                                      |


             % telnet roxy
             % telnet 123.4.5.6


             N           UNIX             ^               K       b               (           C                                                       \hostname"                                                                  |                       \hostname"
             :           (    C                       &                                           9               (           C                                               ^                           9                   (           C

                         .            A       h               3           !                                       2       ]                       UNIX                ^                                                                   b           8       !                (   C

                 K   b   !    (       !                                                           A               9                                               i                   8       ?                                                       ^       %                n               0

             !   8                                            j                                   \                               r                       " \             &                           r                           "       9                           b

                     ?                t       &                                       b                   p                               X       |                                       1           ?               b                                           2                                    \
                     12 2r       " \
                                  ;               r                                                                       12 2        r           ;           r                           "                                                                                                    Q

                 3   \    12 2 "                  r           ;                                               r                                                                                                                               6                           9            F



                          X \ " \                                                                                     "   b                           b   (                                                       \domain"                                                                 9               5

             v       J                                        b                               X                                               `                                   B           *




                                                                                                                                  32
Chapter 2.      +                   UNIX                                                                                                                                                                                                                                                                2.4.             #




                        t               \   (     \ "   C           "
                                                                    |                                                           |                               C                                                       I       ^                                                   J       r       D                    X   |       N

                I       ^               K   Internet                                                A       3                                               9                           G                                       t           &       t                                                       /        )

                                140.113.4.6 140.96.200.1
                                |                                                                                                                                                       9                                       C               )                                                           F            ^

                                             \ "                                        (           C



                                \ " \   1      "                            C                                                                   b                           b           (                                                       \IP"                    T       \IP Address" \IP"
                        \Internet Protocol"
                        9                                                                           F               3           9                   '   '           1                               F                                                   J               A                                                ?   9

                        |               0       8               n       h                               :                                   1               T                                                   .                                                   F                   F                        Q               A       \
                                ^                           |           b                                   IP"                                                     |       a                   \       r       i           "                                                                               1            9




rlogin          remote login                                                                                                          telnet                                    -                       3           y                telnet                             G                                   \username"
                  \password"                                                                    rlogin                                  username                                                        A                           '                       !                                   |             password
                                                1           %                           \   '                               !       "          rlogin                                                                                                   3       G                   ^               b                    r

                v                       r                                       G                                               8       !               ^                                                                       rlogin                                              3                       @

                        ^               T                                       G                   ^                               login               9                               telnet
rsh             remote shell                                                                                                                    rlogin                              !                                       6           b       8       !                   username                                         \rsh
                G       "       ^                                                               G                                                                                   `           ^                                                       `                                   I       ^

                        P                                           A



                % rsh roxy who


                                    roxy                    9                   ^                                   :           :       b                                                                   3                           ^                                                                   3        9

                        ^       blogin roxy                                                                                                                                                     who                                                                                 A

                        \rsh roxy"     \rlogin roxy"
 nd             9                               !                                                                                                                                                                           H
                                                                                                                                                                                                                                                                                19                  9                >

                9                                                       |                        \ nd dir -name lename -print" \ nd                                                                                                                                                                                          R       F

                -name                               0                   j           n           -print"                                    \dir"9                                                                   j                                                           1                                    9

                                ?                                                                       lename  0                                                   9               j           n                   Q                   .                       X       3                   5

                j       n                                                                                                         roxy.dat                                                                                                          0                                                   9            j   n           9

                        3                       `                               &



                % find ~ -name roxy.dat -print
                /export/servTX/fake/users/jacky/roxy.dat
                /export/servTX/fake/users/jacky/tmp/roxy.dat


compress        9                   UNIX                                                    D                           P                                                                   j       n           D                           D                               j       n           |       j    (               \.Z"
                                                    Z                           (                           A



                % compress roxy.dat                                                                                                                                     roxy.dat.Z                                                                          D               j




uncompress          9                   UNIX                                                                D                           P                                                                               D                                                                           j   n            D

                A



                % uncompress roxy.dat.Z                                                                                                                                             roxy.dat


                                                                        D                                       j                   |       \.Z"                        j       n           (           C                                                   J       \uncompress"
                .                               L                               .                   D                                           j                   %               (           C


 19 X   |   A               p       B                                                                                   H




                                                                                                                                                            33
2.4.       #                                                                                                                                                                                                            Chapter 2.                                          +                    UNIX

uuencode           UNIX             to UNIX encode                                                                                                                                               binary                                 j           n
                                                                                                                                                                                                                                                            20                       _       D       W                                       ASCII
                   j   n           |                F                                                   `                   6                                                                   label
                   % uuencode roxy.exe abc > roxy.uu


                            roxy.exe                                            9                   j           n       _       D       W           roxy.uu                                     9                   j           n                                                   \abc"                 _          D                            w

                       \roxy.uu"                            9               j           n                   roxy.uu                                 /                   :       R                                   9



                   begin 755 abc
                   M@0,!"P X     "    3Y&       " @          "\$" T .@0)(#H$25
                   M*B "E *@!)0"0 H7 ! U"+BN ,   C" &((@)   0*   0!    0   "@$
                   M ! #@$ 0     $   Q2<(Z @0 X P$   ! #@$ 0    )WCOV@O  (KA7B
                   M*!$   B0$B(,0   2Y(0( "L$ (D@.@7$   $N4$" @@*(@(!* $\!
                   ...
                   ...
                   M
                   0

                   end


                               |   :                                                        b                                                                                   C               \begin"                                                                 9            J                   uuencode                             j   n

                                                                                    C                                                                           B           _       D                           j       n                           J                       \755"                               \abc"                C

                               3                                                    \label"                                                                                                                     D                       P                   9               _       D                     j          n

                               %        (           C                                                   &                                                               j       n                                                   (           C       \uuencode                                        j       n           (       C        j   n

                   (       C   "                                            B           \uuencode"                                                                                          j           (                                            \label"                                                 3                   D            `

                               W                                (       C                \uuencode"                                                             j       n           t                                   b                             \end"                     C                                    j           n            h

                   c



                           .            UNIX                                                                                                                P                               @               F       X               binary                              j   n                f    A                              B       _        ?

                       compiled                                                     P                   T                   Z       *                                               3               X           9                   j           n                   G                            6               \uuencode"
                   .                    _           D                   Q                                   Email
                           \uuencode"                                                                                               #                               3                   K                                   B                           Standard Output                                                                           X

                   |   &        \ "             t                                                                       \           0       " redirect                                                                                                  j       n




uudecode           UNIX             to UNIX decode                                                                                                                                      B                   uuencode                                        _           D                        ASCII                   j       n

                   W



                   % uudecode                                       roxy.uu


                               G                                                                roxy.uu 9                                                                                                   9                   j           n                   D                        W       abc                                              (

                   C               abc                                                roxy.exe
                                    G                   X           1               uuencode uudecode                                                                                      Email                                3                                                            F    X                  ]           `       &        b

                                            9                                                                   g       )               s       X                               . \uuencode"    j Email     n                                                                                                                #

                       \uudecode"                                                                           j       n                                           X           Email            binary             P                               @       F           X                                j




w                  9               UNIX                                             t           y                                           ^           b                                                                       w           9                                                                        C

                                   G                                                                                    |



                   % w
                     7:23pm up 19 days, 9:28, 10 users,                                                                                                                                                                     load average: 0.05, 0.04, 0.05
                   User    tty       login@ idle  JCPU                                                                                                                                                                      PCPU what
 20    Q       A       E                                        ASCII                   j n                         uuencode                                            |                   9           h                       i




                                                                                                                                                    34
Chapter 2.         +       UNIX                                                                                                                                                                                               2.4.             #




                   John                        ttyp0                                4:04pm          2:22                                                                                        -bin/csh
                   John                        ttyp3                                4:04pm          2:47                               2                                                2       xterm
                   John                        ttyq1                                4:36pm          2:47                               7                                                7       /usr/openwin/bin/xview/textedit
                   Jacky                       ttyqa                                6:24pm            17                            4:24                                                        vi BM_DOP_e.twr


                       9                                                                                                                                            3           `                                 B               ^   9                G

                   b   9   K                   login                9            ^          ^                                                               t                               4   b                 C                                    C

                                           ^                R       '                                               D                           C                                               ^             !           ^

                                                    |                       5               &                                               username                                                              ^                           login
                   `                       B    9               ^   $       "       8       #                                           C       CPU                                 X           `             ^                                        t

                                                            3



                           \w"                              :           X       b                       9                                               T
                                                                                                                                                                                21

su                 switch user                                                                                          3                           ^                           login                                                     `        9




                   % su -    username
                   Password:                                                            D




                                   @                                                D           X                                               $                                                                         3                            W

                                                    B                               \who am i"                                                  N       g                                   \su"                                  @   -




wc                 word counting                                                                    j           n                                                                   C       -        character, -c                                     C

                    word, -w                                                        line, -l
                   % wc -wcl file1
                   967 7842 223 file1


                   \wc"                b                        4                   |                                                                       |                                        3                    X               5

                                           A                        \-wcl"                                                          C                                               C                C    -                                        ^

                                   4       `                                        5           \lwc"                               A                               m                                             C               f   A                :

                   C                            |                   \wc -w le1"
env                                        &    \       (                       " Environment Variable                                                                              '
                                                                                                                                                                                                     22

di                 di erence di erential le comparator                                                                                                                                          f                 j       n               !        9

                                        \ed"    }   P                                       9                       P                   |   *                                       Q                         j   n               W                '

                           E    \ed"
                                   y            !                                               1                                       }   P               b           F                       Z    W            9                                T

                               \di "
                                   |       y        \                                               3                   '       b                   j           n           5                       \name.old" \name"         C



                   % cat name.old
                   Neil Young
                   Bob Dylan
                   James Taylor
                   Lindsey Bukingham
                   Sarah Hickman
                   Jackson Browne

  21                           9                        G                       \ps" \who"          b                       !                           f               :           :
  22       '           (                        \setenv"                            \set"                   J       !       `                   '                   C                       &       C Shell \         '               " prede ned
variable       '




                                                                                                            35
2.4.   #                                                                                                                                                                          Chapter 2.                              +                   UNIX

           % cat name
           Neil Young & Crazy Horse
           Bob Seger
           Bob Dylan
           James Taylor
           Lindsey Bukingham
           Jackson Browne
           Paul Simon


               3        \di "                     :       9                   j           n               -




           % diff name.old name
           1,2c1,3
           < Neil Young
           < Bob Dylan
           ---
           > Neil Young & Crazy Horse
           > Bob seger
           > Bob Dylan
           5d5
           < Sarah Hickman
           6a7
           > Paul Simon


           \di "                                  b                       C                                   -       I                                                       \a"                         \append" \add" \c"                          T

               \change" \d"                                                                   \delete"                                    3           9               C                       G                                                   b                   C

           r       C      G                                       r               E           T   \di "                                                                                       j   n               C                                                       r           E       T

               \di "                                                      j       n                           b               A                       b   \c"             C                                                       :                   \ " \ "
                                                                                                                                                                                                                                                          s           C       t               r

                              C                       5                                                       j       n                                   /                       C                           j           n               /



                   :                                                                                                                  \1,2c1,3"                                                                       name.old    j       n

                   1 2                                         \c" \                  W                               Z       C        "                                                          j       n       1 3
           X         \            Z               C           " \ "   |       s                                                                           j       n                   /                         \ "
                                                                                                                                                                                                                  |           t                                                               j

           n       /                                  1               .                               j       n                               1 2                                                     j       n   1 3                                                                 9

               j   n              1 3                                                                                                                     G                   /                                     \ "                       A           s           X

                          W   A    \ "            t           X                                                                                       \---"                                                   \ " \ " s                           t                   I           5

                              H           B




                    :     \5d5"                                       b                               C                           \               b                                "                                  \d"                                 \   t           " \5d5"
                    1                                     j   n               name.old                                                                5                               *                                                                   j       n        name
                                  t                                           3                                       |       \ "     s                                       \d"                                 \5"                                         B           G

               \1,2c1,3" \5d5"                                                                                                3                           H                   B                   5
                   \6a7" \a"
                   :                                                                  \                   " \6a7"                                                 1                                   j       n                   name.old                                                6
                                                                                                             \ "
                                                                                                              |           t                               3                               \a"                                        \7"  C                                       B           9

           |                                                          B                                    2                      j       n                               7
                        \di "                                                         .                           }                                                                       C    \ItliketUNIX "
                                                                                                                                                                                                  -                   X               |

               \ItlikettUNIX "                                                            \di "                   -                               !               A                      \di "                                        E                   9

                space tab                                                             |        \-w"                                   9                       4                   \di -w le1 le2"                                                             A                               E

               N          t                   9                                                 \-b"
                                                                                                  J                                           4                                     \-i"        \di "     4                   |                                       E

               -




               \di "                  f                                   j   n                               !               A                   f                               j       n                                                           \di 3"                                  3




                                                                                                                          36
Chapter 2.      +                   UNIX                                                                                                                                                                                                                                                                     2.4.          #




                h               9       1
                                                        23

cmp             compare                                                                          f                                               j           n                           8           !                                   \di "                               !                           \di "       f

                ASCII                   j       n                                                                        !                                       \cmp"                           J           ^           b                                                               2                           j   n

                byte     byte                                                    2       f                           Q                                                       8       !           T                       8           !                                                   b       f

                  \comm" \common"                                                                                                                                                .                               j           n           8           !                   2       ]                                   9

                        3     \di "                                                                  K                       9                                                           S                                                                   b                                                                 \

                       \man comm"       |




tar             tape archive                 \ "                                                                                     j       n                        #              R                                   W                                                                                                          &

                           \xxx.tar" \.tar"
                                        K                                                        |                                                                                               j           (                       |           -                   |                   -                           #

                           \c"  4   \create" \v" verbose                                                                                                                                                                                     \t" table of contents                                                                 \x"
                  extract \f" le
                        5               |                                                                1



                % tar cvf my-files.tar /home/users/john/my-dir
                % tar tvf my-files.tar
                % tar xvf my-files.tar


                                                                \/home/users/john/my-dir"                                                                                                                            9                                           |                                                                  I

                                R                       w    3\my- les.tar"                tar                                       9                   j       n                                                                               9                                           4                       \-"       9

                                        \                   "            #     my- les.tar
                                                                                 w       3                       j               n                                                                                                           X           |                   \c" \f"                         4

                j       n       (       C                    3\f"       \v"                                                                                                                                                                                              A                                   K       \              \

                1                                             \v"
                                                                     \my- les.tar"   :   :                                                                        9                                  #                                   b                                                                   :   :

                                                                    \t"  X    \f"|                                   4                                                                                                               j           n                   #




                                                                      my- les.tar                                                                                    9                                   #                                                                                                                     I    J

                                                                          tar                                                                9                                           3                                                       #           `

                `           X       B                                    5                   H                   w                           #           /                                                                       |                                                                       1                     `

                           \/home/users/john/my-dir"
                                    5                                                                                                                                                                        3                                                                               `                                      w

                3   \/home/users/john/my-dir"                                                                                                9                                                           u                       3                               `       ^       b                                             Q

                C                                                        A                                                           `       X           B                                       5                                   9                               \/home/users/john/my-
                dir"                        ^       b                        J                                               ^                                                   9                   j       n                       #                               A



                % tar cvf tmp.tar /usr/bin


                                    /usr/bin                                                                                             w       3               tmp.tar                                                                 3                                   tmp.tar                 `           s                  .

                        #       /                                w                /usr/bin                                                           9                   .                   3                                   `           X           B                           5                       /usr/bin               `

                                t       &                    |                   \/usr/bin"                                  9                                                           J



                        tar                         |                .                                                                                                                                                   A



                % tar cvf tmp.tar k1.ps CTA/file1


                                              \k1.ps"   .                                            3                   G                                   5                                       \CTA/ le1"                                                          3       \CTA"           9

                                W       \tmp.tar"                            9               j   n                       #




                        tar                 Q                        |       3                               #           j           n                                               .                                                           0                                   A



                % tar xvf tmp.tar k1.ps
 23     b   ^   b   f                           j   n                                        ^   b




                                                                                                                                                         37
2.4.    #                                                                                                                                                                             Chapter 2.                                  +                       UNIX

                .   G                                             \k1.ps" \tmp.tar"                                                           9                   j   n                   #                   J




                \tar"         t                                       4               9                                                                                                                                                           9                       9       +               t

                                              j       n                   #                                                                               J                                                                                   #                                        D      3       A

                @         ^       b                                       B                               t                                                           H           9       {




head        9                             .                       j       n                                                                                   4                                                           A


            % head -20 file1


                .            le1              G           20                                                                  3                   K                                   A                                           4                                                   default
                \10"
tail            G                                 8       D                   9                                       .                           j           n                                                                                               4

            A


            % tail -20 make.log


                .        make.log                                                     20                                                                              default                                                 \10"
                                      ?                               4               \-f"                                                                                                                        j       n                           A                                           P

                    background                                                                        P                                                                   0                   \make.log"                                  9                   j       n               .               B

                     0            X       |       3                   K                       :                                                                       Q                   |          \cat make.log"
                                                                                                                                                                                                              `                                                                           T       \tail
            make.log"                         :                                                                                               \make.log"                                                                      B       b                                   ]                       X   |

                    P                         %                   `                       :                                           9       `                                   |


            % tail -f make.log


                  \make.log"
                     D                                                                                                                                \-f"                                            -                                                                                                   \
               " make.log
                `                                                                             20                                                      -                                                                           \-f"                `               Q

            make.log                                                                                          j       n                                                       c                   9       `                               T                                   \Control-C"
                 \tail -f"
                    \                                                                         Q                                                   3




cut         9                     )       (           L                                           \ " 6           j       n                                       v                       \                       6       "           6                                           4           '

            |                                                             1



            % cut -c1-20 file1
            % cut -c21- file1
            % cut -f2,4 -d' ' file1 > file2


                                                              .                   le1         N                                   G               20                  C           -           6                               \-c" \c"                                                     \charac-
            ter"         C        -                                                                       .               le1                 N                                                   21                                          |                       N                C      -   K   6

                          \-c21-"                             3           21                          ^                           F               C                                                                       t                                                       !

                            \1-20"                                            |       6       \-20"   W                                                                                                       .               le1             N                               2 4
            6                         w                   le2                             \-f" \f"                                                            eld                                                                                 5       &               \-d" \d"
                \delimiter"                                           L               |   ''                      }                           5                                                       1               $                       }

                    9                         3       J                           ]       `       &               b                                                                                               3                                   0       a               D




paste       G       1                 cat                                 |       .       j       n       =       #       R                                           8           #                               paste               J                                           j    n      \           "
            2   #   R                                             E                                                                       E                               :::3                    f                       G                           \cut"
            s             \paste" \cut"                                                                   b       F       !                                                                                                                                       &               3           0   a

            D


            % paste file1 file2
            % paste -d':' file1 file2

                                                                                                                              38
Chapter 2.   +           UNIX                                                                                                                                                                                                                     2.4.       #




                 !                       \cat"                       b       !




split            Q       cat
                         b                                               |           .       j       n                        =           #           R                               Q           b                           |                          j   n       t

                     split                   .       j       n   U                   6       W               s            s                               4                                       A



             % split -500 file1


                 .   le1 500             |                                                                   6    W                   s                       s           6       W                   s       j       n           (       C

             |   \aa" \ab" \ac": : :                                                                                                              b                               \csplit"                                                               6   v   j   n




tr           translate                                           9                                           j   n                            C           -                                       `                                   ]

             A                                                           \ le1"                                                   C                                   I           W                           Q               w                   \ le2"
             % tr 'a-z' 'A-Z' file1 > file2


             9                       3           0       a                               +




sort         )   (           L           9                                       j       n                                ]                                                   `                   !       J       4                       A              j   n       /

                     C                   character                                5              4



             % sort -c file1


             9                               b               9               4                       h                9                   +                                                                       b       m                   \                  \man
             sort"
cc           C Compiler                                                                              /              C                     +                   _                           N               UNIX                                      C Compiler
                     4       K           H                                       T                               \man cc"                                 |       @                                                       option
whereis              0                                                   library                                 manpage                                              X   3       2       ]                   A



             % whereis cat
             cat: /usr/5bin/cat /usr/bin/cat /usr/man/man1/cat.1v


                                           \which" \ nd"                                                                                  !                                                                           @                   9                  3

                     ^       b       \which" \ nd"                                                           9




nslookup                             ^                                           ]               t                                                                I   ^           8       E   T                   IP address
             % nslookup ccca.nctu.edu.tw
             Server: oax2.ccl.itri.org.tw
             Address: 140.96.110.211

             Name:    ccca.nctu.edu.tw
             Address: 140.113.5.150


                     |       3                   ^                                                       9




tee              l                   G           1                               |               \ " t                    .                                                           K                                           H

                             j       n           &                                                \                               0           '       "                   B       h           0       '                                             3        K

                                                 A                                   T                                        3       D           w                   j   n               !   `                                           K              J       |

                 \tee"           9




                                                                                                                              39
2.5.         1                                                                                                                                                                                                                                                           Chapter 2.                              +                       UNIX

                                     % cat file1 file2 | tee file3


                                     9                                                       1                       .                   le1 le2                                         =       #           R                                                   3               K                               !           `               .       9                               w

                                             le3                 9               j           n                       .                                                                                                                       l                       X       |                   \ "                             s           W                               (




    le                               9                                                                                       j       n                       l           V                                                                           9                                               ~           b



                                     % file /usr/bin/*
                                     % file /etc/*




2.5                  1




                     UNIX                                                                                    j           n                   l           V




             G               &                   1                           |                       \chmod"                                                                                                                     j       n                           P                           |                                                               \                       j       "
    executable                                                   W                           \                                                                                                           |           .                                               Z       C           j               P                               W       \                           "
                                 .                                                   Z           C           j                                                                   P       W           \                                       "                                       .                               W       \                           j           "       T

                                             `                       UNIX                        A                                           9                                   P                               9                       \                               j       "                                                   Z       C       j                       {       .

                 P



         UNIX                t       W                                                               x                       1                   \                                       "                                                                           \                           "       Q                                                               9

                         T                                                       j           n




       \                                     "                                                                       UNIX                                            :           :       9                       j           n                       t       G                                   Bytes                               %                       :       :       9

Bytes                                                                -                       -                                                       -                                   UNIX                                B           P                           ?                       .               -           I                                   K       B       3

 \magic"                                 j           n                                           /etc/magic                                                                      9                   j           n                       J           B                           UNIX                X           -                           j       n       l       V

 \ le"                                           l                   j       n           l           V           `                           @                               UNIX                                                            :           9           j       n               Q                                                   n               A

    -            j       n                               M               3           \/etc/magic"                                                                    ^           b       B                                               UNIX                                        ^       C           f           B                                           T                   1

    j    n   \data"
                 l       V                                                           X           |                               3                                           \ le"                   9                                                 \/etc/magic"                                                  n                                           &                           :

:   \/etc/magic"                                         9               j           n                       /                           9                                   ^                                           I           5               SunOS \/etc/magic"
0 long 0101555 PDP-11 single precision APL workspace
0 long 0101554 PDP-11 double precision APL workspace
0 string \037\235 compressed data
>2 byte&0x1f x %d bits
0 short 0433 Curses screen image
0 string <ar>System V Release 1 archive
0 long 0x1010101 MMDF mailbox
0 string <!OPS Interleaf ASCII document
0 string %! PostScript document
0 string <MakerFile Frame Maker document
0 string From mail folder


             9               j       n                       |       .       \       \%!"            A                                           j           n                       t       G                                           C           -                                                   UNIX                                                                        X

    \PostScript"                                     Z                   \From"  A   UNIX                t           G                                           C           -                                                                                                                   .                           W                                                               *

O     mail folder                                             UNIX    SunOS
                                                                         A                                                                                                                                                                                           |                       @                                   :               _                               j   n

3   t                                                    \From me to you"
                                                                     C          \ le"                                                                                                                        Q                                                                           :   :       UNIX                            A               -       9               j       n

.   \From"                           W           \tFrom"    F                      UNIX              3                                   G           9                                           }                                               :                                   -           -                           A               j       n

                                                   \From"                                            `                               A




                                                                                                                                                                                                         40
Chapter 2.                           +                UNIX                                                                                                                                                                                                                      2.5.   1




        A                                                      SunOS                                           \%!"                    j           n                                                   }                               :           :   b       %            s

    |                                                            \ le"                                     3               ]               1                       F                                                                       9               j       n



TARGET = p2s2
CFLAGS = -O
SOURCES = main_p2s2.c p2s2.c
SETLIB = -lm
OFILES = $(SOURCES:%.c=%.o)
p2s2: $(OFILES)
        cc $(CFLAGS) $(OFILES) $(SETLIB) -o $(TARGET)
.c.o:
        cc -c $<
main_p2s2.o : main_p2s2.c
p2s2.0 : p2s2.c


            ? C             F                         P        '                                       |       :                                               Make le                                             UNIX {                      1                   %            \ nt]ro ,
tbl, or eqn input text"                                                    A                                       SunOS                                                           &                                       ?       9



        t               3       \/etc/magic"                                   L           |                           b           j           n                                   P                   UNIX                                                            \#!"
                j       n            G                     C       -           \#!"        `                   UNIX                -                                   #   3       \#!"                                                                                     P          3

            |                   Z        C            K                            #   3       \#!"                                                        P


% cat ./run
#!/bin/csh
echo I Love UNIX
% ./run
I Love UNIX


f   A       1           9            j       n                     \run"                                                   \./run"                         `                                       :               \run"                                                G              C   -

    \#!"                                               9               j   n                               /               K                           #       3   \#!"                                            P   \/bin/csh"
                    Q            9               j    n                    P                                       W       \                       "               |                       J                            \permission denied"
G   >




                9


#!/bin/sh
echo I Love UNIX


            !



        b               F                                                                          A                   t  \#!"
                                                                                                                           G                           C       -                                                   j           n       P               B         \      "
                                                 `             UNIX                            '       \#!/bin/sh"                                                             1               .           j   n       /                   W                   Bourne Shell
                                         B                       UNIX                                        /bin/sh Bourne Shell
                                                                                                               $



        X       |                            "             j       n                                                       ]   P           E               UNIX                        1



#!/bin/sh
#
#/bin/csh
# I Love UNIX
(


            K                   W                    Bourne Shell
                                                                                                                                                   41
2.6.         "   .                                                                                                                                                                                                       Chapter 2.                                      +                   UNIX

     6       B           W   ?                   Y                       3           j       n                                   @           2                               UNIX                            j       n                   /                               %



                             9                                   DOS                                                                         3           UNIX                                                                1       g           j               batch le                                        3

                     9           \   1           g           j    "                                                      M               M



#!/bin/csh
cd
cp .cshrc .cshrc.back
cat .cshrc .cshrc.back > CSHRC.double
set lines = `wc -l CSHRC.double`
#   E #F
#   E setF          E linesF '   E wc -l CSHRC.doubleF
echo I have $lines lines in this file : CSHRC.double
echo I use echo to print something on the screen.
echo ""
echo ""


     9                               \       1           g           j               "               A                                                               \           +                               P                   T                           |           "                           9                   P

                     A                                   z                                                                                           :       T                                                                           3           UNIX                                    &                      \    1   g

j "                                  \script"                                                                         \#!/bin/csh"                                                                                       C Shell                                                                     X   |       \ C Shell
Script"              3                       a                       >                           A               \ C Shell Script"


2.6              "       .




y        ^




touch                            9                                           b                                                       $                           j           n                       j       n       `                                   ?               W               G       `               A



                                 % touch file1 file2 file3


                                                                 le1                                 le2                     le3                     `                   ?                           A                       \touch"                                 j       n                           D   3

                                 C                                               (       C                   j               j       n                                       \0"                                     P                               A                                   make le                         s

                                         \touch"                                                         ?           j       n   `                           6                           9




ln                               9                   %           C           =                                   b       n       \   =                   "           3           G                       B       B                           9                       y       \   =                   "               ]   P

                                 9                                                                   :
                                 % ln -s BACKUP backup
                                 % ls -la BACKUP backup
                                 -rw-r--r-- 1 john                                                                                                               8124 Sep 22 12:06 BACKUP
                                 lrwxrwxrwx 1 john                                                                                                                  6 Sep 22 12:06 backup -> BACKUP


                                                                                      \symbolic link"        4       \-s"                                                                                                                                                                                    \       backup
                                             BACKUP"                                              \BACKUP"
                                                                                                     =                                                               5                           G                                                                       9           j               n       T

                                                                 D               3\backup"                                       (               C                                                                       ^       b                           9                                   ]       -

                                         |                       \backup"           \BACKUP"             9           (       C                   D                                                                                                           C                       T                   \backup"            9

                                                     T                              \BACKUP"                                     /                                                                                                                                                               B           9       =

                                                                         \BACKUP"             \backup"                                       9               (           C           T                                                                       K                       !                       j   n       T

                                                                 \BACKUP"                                        =                       ?                       9                           &               X       X




                                                                                                                                                                     42
Chapter 2.   +           UNIX                                                                                                                                                                                                         2.6.     "   .




                         J    *       =                                                       T       j       n                   K               \rm"                                                    b                            b   \unlink"
                                  J       *       =                                                                               J       *       =                                   (                           j       n       T         :
                 % rm backup
                 % ls -la BACKUP backup
                 backup not found
                 -rw-r--r-- 1 john                                                                            8124 Sep 22 12:06 BACKUP


                 .           backup      \rm backup"          =                                                                                       \           T   "               (           \backup"                             t   t

                         V      ( \BACKUP")
                                      (                                                               3                                                   (



                         1                F           9               1               =                                   K                                                       \symbolic link"                                              \ln -s"
                     =                                        b       X           \hard link"                                             \ln"                    P           4                               =                        b

                 |   \man ln"
expand           9                                    E               C       -               TAB                         W                                                                   space                               3    _       j   n   `

                 &                E               C   -                   /               :    R                      J                           Y                       A                               9


                 NameX        X                                       Phone_NumberX                                                   Address
                 r           X    X                                    02-1234567X
                 A           X    X                                    03-7654321X                                                    ~       h

                 W           X    X                                    07-1234567X                                                    {       .




                              j       n                   X                                    TAB                "                                                               5               J                       3                T

                                          9           E               C   -       K            W                                                                          y               E           C       -       X       E   T

                                                                  \ nd and replace"                                           ]                       .                                                                                                P

                                              UNIX                        \expand"
                                                                              9



                     9                                y           BSD                                                         X       |               w       3       /usr/ucb
                 % expand input_file > output_file


                                          /                                                       X       |                                                       0                           j       n                               \cat" \more"
                                                  `           :                   9                                                                               \vi"    `




                     \expand"                 b           8       D                                       \unexpand"                                                                              ?       8       D




uname            UNIX         Name                                            9                                                                               3                   9                   UNIX                                 (   C

                         4     \-a"
                 % uname -a
                 SunOS roxy 4.1.1 1 sun4c


                         3        |                   :                   ^                                                                               OS Operating System
expr             9           P    t                                               3            t                                                  A


                 % expr 1 + 2
                 3
                 %expr 4 - 5
                 -1
                 % expr 1 \* 5
                 5
                 % expr 34 / 7
                 4

                                                                                                                  43
2.7. 1752                       O           9       `                                                                                                                                                               Chapter 2.                                          +                       UNIX

                                                                                                            \\*"                    .                                           \*" C Shell 3                                                                                                       L               \ *"                X   b

                                            j   n                           X       |                               E       a                                                      \expr"                                                           J                               A                           m                   F

                                                                            \bc                 -l   "  9



                                            % echo 34 / 7 | bc -l
                                            4.85714285714285714285


                                                            \-l"                    4                                           J                           J




                b                       ?       {                                                    \sed" \awk"                                        K                                                       +               |           1                           3           9                   ^   b           +

N   A                       .           UNIX                            \                                                                       b                                       B           >                                                                                                               0



        9               a               l       +                                                                                                   UNIX                                                /               b           F           9                                   0                                   A

                                                                        B                       :               b                                               |                       B                       {                           6                   :                   U                   2   ]                               ^

                    ?       b               F




                            UNIX                                    `                                                   s  UNIX                                                         K                       y                           0       G           >                   K                                           b   `   ?

                    X       |                           @       9                       b               .               UNIX 3 s "                                              `                                               ^           *                           ^           b                   3                       ?       D   T

            X                                                   9                                                       Q                       H                                                                               H           9       `                   3                       C                               ?

C                   9                                           ^                                                               UNIX                                            K                                   C       {           W                   b                   #                   Y                       W \
    "                                   q       W                                   C                                       X   |                                   !       y               !                           \move"                                                              ^                       f       \mv"
    1




                0       G       >                           A               H   9           H                                                       .       `                       3       \   :                   "   9                           0           G           >                                `                      ^   >

            X                                                                                                                                                   J               A                                   .                                                                                                                   :

UNIX                        S                                   .                               m                                   H       ^                                                   X       |                           0           G       >                               H       9                                   ?




2.7 1752                                        O                   9       `




UNIX                b                                           \cal"                               \calendar"                                                          |                       `           K               O           K                           A



% cal 7 1995
   July 1995
 S M Tu W Th                                                        F        S
                                                                             1
 2       3 4 5 6 7                                                           8
 9      10 11 12 13 14                                                      15
16      17 18 19 20 21                                                      22
23      24 25 26 27 28                                                      29
30      31


                                                                    1995                O           7   `       `       K               A                                               O                    `                  3           \cal"                                                                                   C

|                   u               3       \cal"                               ^           b                   C                                                               G                               `                           `               `           K                   u               3           \cal"
b                           C                                   .                                C          W   O                                               O               O       K                                                                                                       9                               `

                    *



% cal 9 1752
   September 1752

                                                                                                                                                                44
Chapter 2.             +         UNIX                                                                                                         2.7. 1752   O       9    `




    M Tu W Th F S
    S
       1 2 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30


    t        &        UNIX   K              1752        O           9   `               &   Q   K        11   F             0       |   UNIX          T

    P        '    /                                 O           >   0                   K            u            K       (Julian calendar)       3   &       K
                                                                                                                                                                  24
X   |                            1752   O   ^   b           J           9       `



         +                                  a   &                           /       )       UNIX                      a         D




                                                                                                                 I wanted to design something that would
                                                                                                              still be usable in 100 years. In other words,
                                                                                                                    my goal was to arrange things so that,
                                                                                                                      if book speci cations are saved now,
                                                                                                              our descendants should be able to produce
                                                                                                                       an equivalent book in year 2086 : : :
                                                                                                                            from TUGboat,7(1986), 95-98.
                                                                                                                                       by Donald E. Knuth




    24           \The Gregorian Reformation"

                                                                                                45
2.7. 1752   O   9   `        Chapter 2.   +   UNIX




                        46
Chapter 3

UNIX

3.1                          ?




`        /                   1968    UNIXO                                                            G                   O                   UNIX                             l           Ken Thompson                                                        !           3                    @

                         (       MULTICS                                                                                                                               \           b       n                                                                   @                       GE                2

    )                                ]   '       b                                X       m                   {                   H                                        b                           Z                   8           F                                           '            @

         Ken Thompson                                         w       T                                       y                   '                            O                               I           DEC-10                                                              MULTICS
         b           ?               E                (                                                                       $                       Q                    X                                                                                               ?                        3

!        {           '           n                        g                                       `                                   B       b                                           GE 635   j       _                               P       3                               ^

         D       T   &                   X                                        s                                   I       H           y                                PDP-7 Ken Thompson Dennis Richie
    .                            j   _                    P                                   PDP-7                                           `                            1969        PDP-7       O                   9           I                                   h                        3   J

    \    a                           (   :::

        MULTICS                            \MULTiplexed Information and Computing System"
                                             @
                                                                                                1                                                                                                                                                                                           3       1970
O                `                       PDP-7
                                         I                 2              Brian Kernighan
                                                                          Q                   Y                                                                    X           |                                                                                                   Y

                 @                   \UNiplexed Information and Computing System"         \UNICS"                                                                                                                                              n                                   Q

                                        \UNIX "                                       9                   (       C                                        *        F




3.2
                                 '                                    I           PDP-11/20                                               9           g                                        .                                                       (       L                   s    "       Z   h

                     b                                ]   '                   9                       n                           2                                                                    s       "                               Z       h                                                 3

UNIX                                 Z   h                                        nro                         tro                                 G                        b                                       ^       9                                   @                                I

    2                9                                                                Z                                                                            @                                                   I                                   5       W   a   2       W                UNIX
                                 P                               1971
                                                                  `                                               O                   9       I     PDP-11/20                                                  b       0.5 MB                                                           9       J

         Z                                           \First Edition"                                              ^                               1970 11          O                           `                   h       |                           UNIX                                     |

Z



        1973         O               Ken Thompson                                         Dennis Richie                                                 UNIX                                   J                       C                               h       `               4                             C
    G                    B                                                            s                                                                UNIX                                                            B       +                                   j                   W             C   +

         9                       `                                    UNIX                                                D       |                                                    &                       !               ^                                                   K    &


    14       Q   b           Y                       Many Unnecessarily Large Tables In Core Simultaneously ...

                                                                                                                                                      47
3.3.                        '       v                                                                                                                                                                                                                                                                                                           Chapter 3. UNIX

P   D           J                   UNIX                                            |           3                       y    `                      /                       W                                                                       1974                    O                                               3       \Communications of the
ACM"                    P       s                                       UNIX                                                 S                      ?               9       .                           &                                           1975                                                                O                   6th Edition
                                                                                                                                                                                                                                                                                                                                                    0                                                          s

        9                                                                                                   @                                                                                           1977                    O            UC Berkeley                                                                                  Pascal
                                                                                                                                                                                                                                                                                                                                            2                                                                  =

        s                                               E                   6th Edition                                                                                                 P               D                   9               X     \1 BSD"                                                                             1st Berkeley Software
Distribution                                                                                x                           UNIX                                                                                5           Y                   BSD                                                                                                                                 a           .                  3

UNIX                                                                                                    @                                                                                                   /           )                                                                                           2                       |           C                   ]                        Western
Electric Co.                                            "           y               D           Z           Z                                       !                                                                                           UNIX                                                                                                                                .   h        /    I

    $                   Q       ^           b                                   E               UNIX                         b                                              Y                                       UNIX                                                                N                                   3           ^                               x                             Q

Dennis Richie                                                   Ken Thompson 1979                                                                                                       O                                       Ken Thompson                                                            3                                           >           0

    C                                       .                   W                               UNIX




3.3                                         '               v




                E           UNIX                                        m           O                                   9                                                   @                                   -                                                                               0           J           !           J                                   UNIX                     |             ^

b               Y                                                               1           J                                                                                       ^           b                                   0




                                        =                                   2                       /           I                   b                                               9                                   3                               UNIX                                                            @                                       -       W                                      Y

  UNIX                              $           #                                       UNIX                                Support Group USG                                                                                                               9               $           #                                               Y                                                                 s    "

UNIX                                                    9                       !                       0           l                   N                                               UNIX 2                                              ]           K       3       s       "                                                       UNIX                                        ?                     UNIX
                        P                   K                                           UNIX                                    R           s                                            UNIX 3                                                                             %                                   b                                   9                                   9

    n   "



   1979                 O                                   7                                       V7     K&R C Compiler Shell         PBourne     s                                                                                                                                                                           C

Shell                       9                                                                         last true Unix Stephen Bourne Bourne Shell
                                                                                                        t                                                               UNIX
                                                                                \an improvement over all preceding and following Unices"
                V7 Bell Lab                                                         s           "                                                                       32V                                                                     UNIX                                        3               32-bit VAX                                                  ^                                      (

                h                                                   3           s               "       `                                                                                                       9                   32                          -                               \                  PDP-11
                                                                                                                                                                                                                                                                                                                        W                                                                                 E

    B   7                                               {                                                                                           1                       .           &                       P                                   @           j       {                                   X           ^           b                       B       7                                 9

                b       (                               a       B               7                                   Virtual memory                                                                                                                              "               9                           ^                                                                                   UNIX       /

    W3 BSD                                                                  .               h                       BSD        UNIX                                                                              kernel          \vmunix" Virtual
                                                                                                                                                                                                                                        m           T                                                                                       (

Memory UNIX                                                                                                                     UNIX                                s       "           $               Computer System Research Group CSRG
                                                                                                                                                                                                        #

9       #       ;                       UNIX                                            W                                                       K               l       y                           z  1980           4 BSD 1983        4.2 BSD O           s                                                                                                                   O

     TCP IP 1986                                                                        O                       4.3 BSD                                                                             TCP        1988       4.3 BSD Tahoe 1990                                                O           b                                                                                                  O

4.3 BSD Reno 1992                                                                           O       s              4.4 BSD                                                              3           9       CSRG            O   BSD UNIX                                        P           n               T                   X                                                                         P

    a                           G                       .                       P                           UNIX                            s           "                                   |           3                Mach
                                                                                                                                                                                                                            /                           d       (                   .                                                                                   t           b   (             t   b    W

                                    UNIX                                                                                                                                        P                       w/bin       3               BSD             9                                                                                                                                                 X

                                P                               w               3               /usr/ucb                                                                        |           -           b           X/usr/ucb                           9                                                                                       9



                    @              Programmer's WorkBench(PWB)                                                  UNIX                        s               "           I                                                                                                                                                                                                                   s    "

             UNIX             Dennis Richie Ken Thompson    PWB/UNIX                                                                                =               !                                                                                                                                                                                                                       .         &

            UNIX               1982 USG PWB                      UNIX System                                        9                                                                                           O                                                                               )                       W                                   $       #

Development Lab. USDL                         UNIX    UNIX System III                                                                                                                                                                                                                                                                                                                            9

    t                        UNIX
                                D          1984                     ]                                   2                   0           J                                                                                           3                                       O                       .                                   4           Y                               8       D    Z    Z

X   AT&T                         UNIX       t  AT&T Information Systems
                                                                W                                               2                               3           9                   G                                                                                                                                                                                                                              3

1983        System V 1984
            O       s                 AT&T                     UNIX                                                 3                                       O                                   X                                                                   y               |                                       m       ;                                                            `

v   -         UNIX      UNIX        1984 AT&T          UNIX System V Release 2                              Y                                                                                                                           O                                                   s

  SVR2 1986        SVR3          1988           4.2 BSD SunOS       O                                                                   8                       W                                                               O   ?                       )                                                                   C                                                                         W

SVR4
        1991                O           4           `                           AT&T                                W                                               2                           UNIX                                System Laboratories(USL)                                                                                                                    UNIX             9




                                                                                                                                                                                                                        48
Chapter 3. UNIX                                                                                                                                                                                                                                                                                                                   3.4. Richard M. Stallman

-   USL                          X       =        b                           1993                        O                                                                               Novell                              2                                               USL                                 Q                               UNIX                                                    ,

X/Open UNIX                                                                                                   A                                                                                                                                                                       y           UNIX
                b                b                                                                O                                               W           W                                           b           *       F               W       !           ?                               UNIX




3.4 Richard M. Stallman

                 ^       b                                        9                       t           &                       &           Q           b                       M                                           3                                   P                                                                                                                                       b   ^       b   W

        GNU                              3                                                    -               I                   :::

        Richard M. Stallman                                                                                                               j               6                                   .       o                                                       @                                                                           J                                   O               K       3

    `                    #       =       y                    P           '                                               \                                                           I  Lisp Machine                                                                                                                         @           ~                                                   @       ~               8

    #                            `                                                    `                           b                   s                                       P        bug                                            y                               b                                       x               .           h               P                   s       "               "

  1980                   b                                                            MIT                                                                                         Lisp Machine Inc.                                                                                                            LMI                            2                                                           J

Symbolics                        2                                                    K                       '               MIT                         )           V                 Lisp Machine                                                                                                                                                  K           !                                       Lisp
                                                                                                                                                                                                                                                                                                                                                                                                          3

Machine                                                               K           h           AI                  @                                   =           b                       9                               |       @               1       J               @           s                                   M                                                                                 AI3

@               `                                             O                               Symbolics                                                                               /           b           Q       3           )           V                                                                                   -               )           V                                   1    MIT
|   =       b                    2                                @           ~       W                                   Q                                                       MIT                                 h       W                                                                                       .           h                                       |       /       c           MIT
          LMI
            W                                             5                                   9                                                                       B                       e                                               )       V                                                   8                                                                                               Lisp
Machine          Richard Greenblatt  s                                                                                                                                                /           7                                                       Richard Stallman                                                                    @       3                               T       D                   y

X      Symbolics                                                      /                                                                                       ^       |                                                                                                 Lisp Machine  `                                                                                                                               f

Symbolics                                ?                                                                                            3           |                                   ^                                                                   Symbolics                  Stallman                     b

  MIT LMI                                                                 ?           ?                                                                                                                       K       &           `                                                    Symbolics
    e       *            Q    AI                  3               h           `                                   #                                                           @                                                       @           ~                                                                                           S                                                                       t

  Lisp Machine                                                            ^                                                                                       "                               Richard Stallman                                                                                y                       I                                                                               @

Symbolics                                                 J                       8                                   &                                                                                AI                                         @                                                           ^



        Xerox                2                            X                                   I                                   ^                               AI              @                                                       `                                   ^           &                                                   .       h               @       ~                       .           w   3

9   ;                                                         2           F                                   3                   R                                                                       =           #                                                           W                                                                                                           '

                         ^                                                    T                                                                                                           `                                                                                                                                `                  9       I                               ^       !

P   D           source code                                                               X           |                                                                                                                                           |       ?                                       F                                               X



                     1978 Xerox          O                                                                                            I                                   ^                                                       !               source code Richard Stallman                                                                                                                        /   7       1

    `       ^                                     P                       X           |                                                                                                                                   .                       3       y  source code Richard Stallman
                                                                                                                                                                                                                                                                          ^           b

            1                                                                                         V                                                                       V                                           g                       `                                               &                                       0                                                   C

                                                                                                                              i           i                                                                                                                           9                                           "                                                       Richard Stallman
P                        9                                                             X              T                                               9                       8                                                                                               \           8                                                   8                       2                       W                   w

            y                    3               1984                     O                                                                               MIT                                                                         C                                                                                                               X               b

            y                                                             \           {                       T                                                                                               y               UNIX                                                        P       C                       C                           v                       UNIX
                 }                           P    X                           W                                                               UNIX                                                                                                                                .           J                                                               \GNU's Not UNIX
"                    \GNU"
        G            1                                                                        .                           CSRG                                                                            UNIX                                                                                                        v                                           UNIX                                        source
code                                         y            UNIX                                                            AT&T                                X           =           b                   X           |                                                               400                         Y                   '                           @                                   UNIX            Q

                                                  .           h                                                                       '                                                               UNIX                                                                                        '                                   @                                       UNIX                        0       J

                CSRG                         .        B                                   0           J                                                                                   n           T                                                           CSRG                                Q                                   b                                                           y           P   D

    |                            N                                K                       |                                           K                           |           s                                   F                   y                                                               "                                       X                               P       D               2               @

    8                    M                        X               f Richard Stallman                                                                                                                                                  9                                                           .                   UNIX                                                    N                       P   K

*           Q                    .       m        T           (kernel)                                                                        *                       .                       P           D                   K           2                                   9                                                                                               |       b

UNIX  |                                                       9                           UNIX                                                                                    UNIX                                                                                        }                                       UNIX                                                                            y       AT&T
  UNIX


                                                                                                                                                                                                                      49
3.4. Richard M. Stallman                                                                                                                                                                                                                                                                                                                Chapter 3. UNIX

        Richard Stallman                                                                    -                           8                       T                                                                                       N                               K       T           b       J                                                                                T                   y

            9                                                           P           '                   /           M                       K                                                                                                   Richard Stallman                                                                1                                        |                       8

                                        b                               N                                           8                                           K                                                       P                                                       ^                                       P       '                   /

                                |                   D                                                                                                                                                                   @                                   3                   b           9                           2                   D       3                ?                               1

    ^       b                                                                                       P           '                       /           :::

                                                                            8                                                       Y                                       b                                                                                                               n                           .                                   K                |               J

P   D               X           |                                       H           T           0                                                       X                                                                                                   P                                                                               N       0                                    9               |

            P       '                   /                                           ^                                                                           3                   8                       2                                                                   {                                                           p                                            ?

    8                                               n                                                                                                                               ?                                               8                                           ?                                       8                                                                ?   {

            ?       9                   3                       bug
        Richard Stallman                                                                                    F                                               D                           x           L                                                                               J                       -                       8                                                    @

`                                                                       `           K                   B                                                               ]                       %                                   W                                           f           A       1                                                       b                            ^               W

                                                                                                                                            8                                       9                                                                                                                                                       |                            -                       8

                                                                        J                                           P                       b                                                               E                                               Q                   ?                                       A                   b                                                        G

    I                                               T                               %                   c                                               5                                                   -                                                           M                                                                   u       b               .    h               l

?                                                           9                                   X                                           J           1                                                               ;                       9                                                                                                           "       Z                s   "               C

    K                                   P                   i                                                       3                       &                                                   &           Q                                   Q                                                                                                                   &            }

                                                                                                                            H                                                                       "                                               M                                           t                           b       f           9           ?        "



                y Richard Stallman
                            9                                   F                                                                                                           {                                                       j                                                               8                                                       W                    \Free Soft-
ware Foundation"(FSF)                                                                                       ?                                               K               Y                                   HP                                          (           2               #                                       ^                                                =       UNIX
    AT&T                                    K                                                           9                                                                                                               Q                       &                               P                           Richard Stallman                                                                     r

i                               L                                                                                               P           '                   /                   K           r                                                                       i                                   f           R       3                                                        i   @   @

W   f                                                       |                                                                                       9               K                       T                               w



        9                                       b       9       K           W                                                                   9                                           EMACS                                                                                                                               GNU                                 C Compiler (gcc)
?                   2           -       P                                                                                                           `                                                   8                       ?                                           L       L                           {           n                                   G          GNU
                                                                                                                                                                                                                                                                                                                                                                             J

                                        m           T       (kernel)                                                                            m       T
                                                                                                                                                                2               W                   GNU                                                     |                                                   UNIX                                    W            }                   v       J




        GNU                                 8                   3                                                       |                                   J                                                                                                                               ftp site                            K                   b                    GNU
            D       w               GNU                                                                                                                     K               b                                                                                                                                   |                                                                                |       |

    w                                                                                           9                                                               c       b                                                                                   P                                       Richard Stallman                                                                     s               X

    \copyleft"                                          |           -           b                   y       \copyright"
                                                                                                            F                                                                                                       9                                                       GNU                                         P                   |               G        1

                                                    y                   b                           Public Domain                                                                       8                                                                               w                                               |           3       N                            GNU                 8           /

0                   Z



        t                       GNU                                 8                                       t           &               &           2               b                       9                       3                                   9                               8                                            Linux
                                        |           3           PC                                                      UNIX                                                                                                                                                                                                     Richard Stallman
    \FSF"                                       \                       8                                                       " \Free"                                                                        f           \                           "       ?                   L               \                           "
                                P                                                           Q                                                                                   %




                                                &                                   s                                                                                                   8                                   {           K                       D                                                   9                   Q                                3       K           ]

                                -       y                                   F           L                                                                   s                                                                   {           K                       |       \.gz"                                                                  \.Z"                                              1

                        J                       GNU \gzip"                                                                          P                                                                                                                                                           UNIX                                            \uncompress"
    \.gz"                           j           n                                           %                                               UNIX                                        \compress"                                                              D                                       @                                                                                        UNIX
    \compress"                                                  D           W           \.Z"            j                       9                                                                                                                                       |                           W                           UNIX                                     \uncompress"
                                                    3 \        "8                                                                                                                   z                               \compress"                                                  X                               algorithm                                   &        Q               b

                    1                               \compress"                                                      D                                   P                                       h                       P                                                                                                                                                                J               E

y                       UNIX                                                            1               9                                                       Q                                           D                                       UNIX                                                                                                X                    E       \           "       8



    2   GNU                         m       T               \Hurd"                                      3               Mach

                                                                                                                                                                                                                50
Chapter 3. UNIX                                                                                                                                                                                                                                                                                                                                                                       3.5.                    _




                1                   j                                                     .                                                                                       v                                                                                                       X       |                                                                               \gzip"                              D

                8                                                        \compress"                                                                   6                ^                                  X




            n           y           X            \       8                                            "                               b                                                                                                                       \The League for Programming Free-
dom"(LPF)                                    9                                                            3                                                       4           |                                                           a                                                                                               8                           T               b

                                    FTP ftp.uu.net:/doc/lpf
                                                 .                                            b                                           \                               |           D                                                                                                                                                               J               8       n                       G            T

D    World Wide Web (WWW, W3) http://www.lpf.org/                                                                                                                                                                                                                                                                             T                           #                               Email
lpf@uunet.uu.net                (Apple)                                                           |                                           E           (                                                                                   \       2                                                                   B           S       R
                                                                                                                                                                                                                                                                                                                                                                                                          3
G   UNISYS                 GIF4                  9LPF                    2                                                                E                                       j       n           }           P               =       b                               J                                       E           h                           2                                       E       (
                                                                                                                                                                                                                                                                                                                                                                                                                          5
|                LPF                                                                              s                               G       >




                    Although recent news has been hopeful on the user interface copyright front,
                    the software patent front is getting worse. There are now over 14,000 US
                    software patents over 4,000 were issued in 1994, and the rate is increasing.
                    Most programmers oppose software patents, but our opinions don't count
                    unless we speak up. One way to speak up and be heard is to join the League
                    for Programming Freedom.

            3       9                                    P                       J        {                                   `                                       &           &                   K                                                                                                           -                                                   v                                                       m

O                                       FSF          C               LPF                      X                                                   G           >                                           T           &               &                                       |                           0           /                                       D       6                                                       P

    J                       ~       b            Z                                   M                                                    T                               "           B       h           s               "                   C                   K           I       5                   P                                                                   b                       `               J




3.5                             _




N       UNIX                                                     b                                                        vi          A                                                                       A                                                       K                                                                                       ^       b                   1           .           UNIX
                                        vi                                                    :                                   UNIX                                                        h            vi                         K       .       .                           1                                                                                               J                           &

3               |                       Openwindows                                                                                           textedit                                T           X-Window xedit                                                                                              _                       j       n                           5                                                   3

20      9           O           G        UNIX                                    s        "                       `                                                   K           _                                               9                                                                                                       3       .       l                               CDC Cyber
    _                                            _                                                                        Delete                              *                           C           -                                                               cursor                      E                                                   \D"                                             _               j       n

                                                 3           9                       G                                                                                                    X           |               &                                                   H       .           M           vi                                  vi
Bill Joy                                             !                       ^                                                        C Shell                                                                                                                     1                   A                                        vi                                     9

                                                                                     W        1                   &                               3           :                               vi                              @                                       J                                                       Bill Joy                                3

?       user-friendly                                                            F                                                                                                                *                                               L                                               s                                   `                       B                           C                                   ^

b   n                                            ?           w           a




                                    vi                   b           #                    _                                           |                                                                           +                               _                                       K                                                                       |       3        Shell
                        9                                                \ " >                                                                                                                                                            b       9                   ?               tool                        |                                       +                   \emacs"
            Emacs                                                    _                                        t                       _                                       #                               |               3                                           game                            \                       X           mail                                                                            |

               Shell
                *                                                                                                                         Richard M. Stallman                                                                                                                 A                                       t           &                           P                           t           9

&                       3                |                                                                                    9                   ?                                               8                                                           t       b           Q



  Emacs                                                   \emacs"                                                                                                                                 b               /                                   tutorial                                            |           Q                                       W               B

emacs                       `                    \Control-X + Control-C"                                                                                                                                                                          Q                                                           EMACS                                           B                                                               A


        3                           \    2                                       8            (Microsoft)                                     C                           (Hewlett Packard)                                                               +                       3                                       \Look and Feel"                                                     '                   F               9

    n                               ?                .       h               LPF                      b Apple             E                                                   h
        4   GIF                 j                                                                         D       }           P                       X                               D                           J                                   !                           LZW                 D                                   UNISYS                          =   b       h       D                           8

                            A       h    E              GIF                              j n          }       P                   8               s       "                       O               }           J
        5                           E   v            (Lotus)                         2                                3                                   &           (User Interface)                                                                            J               3                       E       (




                                                                                                                                                                                                                  51
3.6.                                                                                                                                                                                                                                                                                            Chapter 3. UNIX

             9                   t           &                                   UNIX                                                                     emacs                                                 vi                                              V               8                                           A       !               vi           E

UNIX                             W                       1                9                                                                           _                 @       3            p           1              ?                               L                           b           DOS                     B



         b                               Y                           PC                                      _            WordStar Borland                                                                                                          Turbo Pascal                                                                                                     UNIX
             1                                   b                           "               Y                   \Joe's Own Editor"                                                                                                                         C  \joe"
                                 H                                                           v                   `       on-line help                                                                @                          A                             Turbo     B       !                                                                               Editor
                         H           T           b                                       !                                        PC                                                                                                            |       3               UNIX                                                !                   ?                     _




                 b                                               C               PICO                                                        \pico"                                                                                                     Editor                              ^       b                           0                                         E

                     _



                             1                       9                   editor                              K                           \                     UNIX           "6        b                                       A                                                   UNIX                                        ^       b                        |

        SA           H
                                             7                                9                                                                   P        w    3           /usr/local/bin                                                                                              |               :           :       9               2           ]




3.6

;   Z                E           y                                   W   x           C                                                           Ken Thompson                                b           ^              b                               F                                                               b               g

                     A                       b           ^                                           '                       UNIX                                                                                                       1                   &               B                   3           creat()                                 C                         e
                     :::



;   Z                        SUN                                                             2                                       (                                                                                                                  .                   Stanford University
                     Motorola 68000 CPU                                                                                              '                                      \                            x              ^                                                    \Stanford University Net-
                     work Board"     \SUN"                                                                                                                                  .            h              '                           0           J                                       2                                   y       W                                     h

                                                         C                           ^                       UNIX                                                           ~       M   s            "                                      3       k                                                                               |                            (

                     (                       W    1982               y                               O                   2                   \Sun"                  Y       }       |                                                               I           5                                           W                       n           "           T    &

                                 1           SUN Board                                                                                       '                                      Andreas Bechtolsheim                                                                                            |           C           BSD UNIX
                                         Bill Joy                                b       n




;   Z                                        b           F               8                   Q                               9                   2                      y                                                     Windows NT                                                                    3           h           G                       &        UNIX
                                             \                                                                                               COSE OSF                                       \                               Novell 3.5                          |                                   Y           -                  USL                                    &

                     UNIX                                                                            b           \   $                   "                                                       E              (            NT       UNIX                          G                                                           AT&T                        X    =    b

                                     AT&T                                                    s           "                                       UNIX           9           K           b           n                   UNIX                                                                                            b       F                                b

                                                 s           "           NT                      x                   r           0               David Cutler                                 Microsoft DEC                                                                                         2                   0                                   9             3

                     DEC                         `                                       r       @       s                                                      3                           DEC         VMS                 `                           .                                                                                                             VMS
                     3                                                                   UNIX                                ^                            DEC               ^                    NT UNIX            3                                                                                       E                                                        Cutler
                                         T                               A



                                                                     Windows NT\                                                 b       F                      H                       UNIX                            "                           P                                    \NT                            9                                       UNIX          "
                                                                                     \               9                                                                                          X            \      %                                       UNIX                        "   9                                                                    9

                                 L                                                                                                                    %                                                  9                                                                                                              ~                                   J    \

                     &                                                               H               p                               :::



        6b       \                                   unix"               9 /
        7T                               H                                |                                      E                           W             9            {       H                           P




                                                                                                                                                                                52
Chapter 3. UNIX                                                                3.6.

                                                                           :     A       b       !   1   :
                      \       1   J                        &       .   9                                 "
                  @       9           1    ~   4   1   ~       J                     {       8


                                                                               by Richard Stallman




                                          53
3.6.        Chapter 3. UNIX




       54
Chapter 4

                       $               C Shell

    B             \ "
                  $                B                           login                                                                                              X   b                               K           b

n           UNIX           Z           2       ]               -        @       .       &                                 ]                           '                                   (           I   5

    K         m    b   X               \   '           "       Shell                2               H                 X       |           b                                   j   n                           9

j   n         _                        |       '                            UNIX                        (    |       C Shell                                  9                       (               j   n   &

3             a    1                           \.cshrc"             T               3       N                                                                                 1       N           K   b

            \.cshrc"           &                                   C Shell                      (




        3                                                                   V               account              `                T           Q                       n   ?                   y                   (

    \.cshrc"                       3               |   :   :                                                 \.cshrc"                 T           :       :               9




4.1                                                    .cshrc
# @(#)Cshrc 1.6 91/09/05 SMI
#################################################################
#         .cshrc file
#         initial setup file for both interactive and noninteractive
#         C-Shells
#################################################################
# Set openwin as my default window system
set mychoice=openwin
#         set up search path
# add directories for local commands
set lpath = ( )
if ( ${?mychoice} != 0 ) then
    if ( ${mychoice} == "openwin" ) then
        set lpath = ( /usr/openwin/bin/xview /usr/openwin/bin $lpath )
    endif
endif
set path = ( ~ $lpath ~/bin /usr/local /usr/ucb /usr/bin /usr/etc)
#set lcd = ( ) # add parents of frequently used directories
#set cdpath = (.. ~ ~/bin ~/src $lcd)
set noclobber



                                                                                                            55
4.2.                            (Prede ned Variables)                                                                                                   Chapter 4.                        $       C Shell

alias cd                                                'cd \!* echo $cwd'
alias cp                                                'cp -i'
alias mv                                                'mv -i'
alias rm                                                'rm -i'
alias pwd                                               'echo $cwd'
set history=40
set ignoreeof
alias h                                             'history \!* | head -39 | more'
#alias ^L                                              clear
alias m                                              more
alias type                                          more
alias dir                                           ls
alias ll                                             'ls -la'
alias +w                                             'chmod go+w'
alias -w                                             'chmod go-w'
alias x                                              'chmod +x'
alias bye                                            logout
alias run                                           source
#alias lp1                                             'lpr -P1'
#alias help                                            man
#alias key                                             'man -k'



        9                                       .cshrc              t       |       \#"                                                 |           N                 b                           L           |

    X       X   1                   T   D           9           1                                .                        C Shell   *           3               UNIX          `               z           N

M           e       X                                                                                                 UNIX          C




4.2                                             (Prede ned Variables)
&               /       3                   a   X                                        A               ?                                  r       system prompt                                 C Shell
                                    r           y       5   f           r           \        Z           " %              b             }                             |

            \set"               A                       T               r           \I       Love UNIX >                  "                                     \ "                   |           9




% set prompt = "I Love UNIX"
(    b    E =F   r




                                                    '                           r            G



%
% set prompt = "<Is it true ?> "
<Is it true ?> echo "hello" (                                                                    r           W        '       )
hello
<Is it true ?>


t                   r       |                                   b                                    |                              L                   &         :       :       9                   \       '

            "(predi ned variables)                                                                   '           ]            '                 \set"       9                         +




% set variable = string

                                                                                                                 56
Chapter 4.             $           C Shell                                                                                                                                                         4.2.                                                    (Prede ned Variables)

E              \                                                           r           "                                       T                   z                       \variable"                                                                      '                                   \               '                     "   (

C   \string"                               9               \           '                                   "               W           %                                                                           1                                   C                                                                           \="
r




prompt                             '                                               r                                       P                   3                       1




path                               '                                   0                                           5                                   5                           DOS                                     PATH                v                                           A




               % more .cshrc


               `                               A                       0               more                        9                                       Q                                                                                                           1                   ?                                   F

               '                                                                               P                       Q                           .                               \more"                              w           3

                       \more .cshrc"                                                           `                                                   9                                                                                   more                                                                                    more
               P                               n                       :                                   path                    9                                                                               '                     path                                      9


               % set path = (                                                              /etc /bin /usr/bin /usr/ucb /usr/lib ~ .)


                                   \more .cshrc"                                       `                                                               /etc            9               0       b           ^       b                               \more"                                              j       n               b

                                                       ^       b                                                               /bin                                        0                   A                   ^           b                       /usr/bin                                                            9        0

                           h       v   .               X       |                                       &                                                                       X           3                               5       w   3       G                                   |                   y                            0

               `                               A                                                                       \                               "           P                                                                                               {                               P                   X       3         5

               w    path   3                           G                       F                       2       ]                                                               s                                                                                                           Q           1       \command
               not found"                                      T                                                                                                                                                                                                                       9           `                   T

               which                                           @       -                                           :       :                   9           `                       path                    '



                                   Q                                   |                                                   5           (                                                                                               A


               % /bin/who


                                       (                                   /bin                        9                                                       who                                                                     \set path =                                                         :::     "                L

               0




cdpath             9                                               '                       ]                                   }           P                                                                       path                                                        K                                                    5

               /               )                       !                                                                                               path                                                                                        `                                                               0

               5                                           cdpath                                  )           (                       L                                               \cd"                    9                                                                                                               A

               3                               UNIX                            `                                                                                                                                                                               '                                           /mail,                        /,
                       /homework/math/linear, /homework/math/int                                                                                                                                                                                                               |

                       \cd /homework/math/linear"                                                                                                              9                                               Z           C                               {                                                           `


               |                       C      \cdpath" 9       `                           m                       ?


               % set cdpath = (~                                                                           ~/homework/math/linear)


               9             C Shell \cd
                                   '            "                                                                                                      (   C                                                                   `           8                       3                                                   5       0    !    (

                          \cd /homework/math/linear"
                                   X   |                                         \cd lin-                                                                                                          9                                                                                   3

               ear"                         \cdpath"
                                                   |        \cdpath"                 \lin-         s                               b           '                                                                                                                           X                                           5       0

               ear"       \ "        \ "       3              \ "                                                                                                                                                                                                                                      0               b

               cd                    \ /homework/math/linear"
                                                           J                     \linear"                                                                                                                                                                      0           :           b       ^           b

                                 /homework/math          linear        3                                                                                                                       0                                               9                                                                               1

                                    cd                                  (current working                               9                                       G                   3                   G                                                                   5

               directory)                                     cdpath       0                                                                                               Q                                                                                           X                                                       0



                           X       |           A                 linear                `       X           3                                                       ?                   b

                 /homework/math/linear       \              linear"                                                                                                    G                   5       9




                                                                                                                                                   57
4.2.   (Prede ned Variables)                                                                                                                                                                                                                                        Chapter 4.                                                           $       C Shell

                                                                                                    cdpath                                               cdpath             path                    &           '                                                                                                   '                                cd
            `                           f                   j                                                                                          path     5                               A                                   '                                                                                   N                        K

                            5           (full path)                                                     A                           \/bin/who" \/bin/cat .cshrc"                                                                                                                                                                                 ^   b

       b    !               G                       B               N                                                           X           3    path   2                               4           Q                                                           b




                                        b                           b                                                                               |                                                       A                                                              SunOS                                                     v       b   '   \cd-
       path"                                    cdpath                                                                  b           \               G                       5       "                                                       1                           cdpath   \ "
       3                        cd                                      3                       G                                   5                                                                   J                   E                                              \      "
                    \                      " \cd ./             "                                   \cd                                                         (                                                                                                       (   "                                                    %

                                  \Permission denied"       T                   K                                                                                                                                                                           G           >               \./             n

                : Permission denied"
                    (                                                                                                                                                                   G                           Q                                               \       : No such le or     (

       directory"                                               %                           9                                               F           L                                                                                                           SunSoft
mail   9                                                                                                                                                                                    j           n                                                           |           -                   `                                A           ^   b    '

            9                                                                                                                                                                                                                                                       *               O                   /usr/spool/mail/\
                    username"
                                    5                                                   UNIX                                                                                                                 /usr/spool/mail                        w           3

                                    3                                                   j           n                       |                                                                   username                                                                (                                                                        A

                                            \John"                          9                                                                                                                           \/usr/spool/mail/John"
                                                                                                                                                                                                                            w           3                                                                                                            9

                                    j       n           /                                                                                                                                                               w                                       j           n                               A                    j   n           B   D    3

                                                                                                                                                                !                   3           j           n                       t                                                   X       |                       A

                                                        z               *           O                                               9                       j           n                                                                                                                                                                            c

                                                        9               \       *       O           "       4           Q                       \                           "   j           n                                                                                   W                               y                *           UNIX
                                                                        b                               ]                                   5                       N                   *




                            1                   mail                                    '



       % set mail = ( /usr/spool/mail/                                                                                                                                                                      (           C                   )


        X   |               3                       b                               *                                               `                                           .           9                                                   *                                               \/usr/spool/mail/
         userame"                                                               Q                                   .                       9                       j       n       b                                                                                               -                    \You have
       new mail."
                                                p                                                               y                       9                   j                   :                       b           ^           b                                                                   Q                                                     b

                                                                                                                            `                                                                                           N                           10              5                               :                       g        A

       10       5               H                                                           |                                   9                       `                                                       3                   r               / \/usr/spool/mail/                                                                                   (

       C "              G                                                           C                   |           J                                                                           |


       % set mail = ( 300 /usr/spool/mail/                                                                                                                                                                                          (           C                   )


       9                                        N           \300 "              J                       :                           g           *       O



            t                                   *           O                                                       |                                               O                               Q                                                                                   j           n                   t

       j    n                                               \Message Of ToDay"                                                                                                      j\/etc"     n\/etc/motd"                    3                                                                                                                         )

       (            L                                                                                                                                                                    \ "        3           9                       j           n                                               2

                            4                               .       h                   9                           j           n                   N                                login                      N           g                                                                               :                        .           H

                    X       |                                                               login                                                                                       (/etc/motd)         9                       j           n                                                                                    3           K

       Q                                |       G           1                           \                                                                               .cshrc .login                                                                   j                                                                                    t

       2                                        4                                       T                       f           A           1                                \              F                                                               ^                       m                   n           ^                F               &

            `                           H       4                   "                                   m                                               N                                                                   G           >                                                                                                    G   >

       /etc/motd                                    9               j           n                   9                                   N                                                       login                                                                           |           :                                    Q                        3

       b  login                                             `                                                                   A                                           B               login                                                                                                           3                   login                     A




                                                                                                                                                    58
Chapter 4.       $           C Shell                                                                                                                                                  4.2.                                                     (Prede ned Variables)

              \/etc/motd"                                                b                                        G       >                                               :                            9                                   G       >                   9                           |

             mail                9                                               =



             % set mail = ( 60 /usr/spool/mail/                                                                                                                                            (           C               /etc/motd)


             9                   '                                                                           N                        60          J                           5                                                :           :                                       *       O       |   C

             /etc/motd                               9               j               n                                                                b                                    s           G           >                                               A                               3   N

                     5                       `                           D           s                   \/etc/motd"                                      b   X           ?                    `                                               :                        \New mail in
             /etc/motd."                                     C                                           3                                    K                       9                                                                                :       :       \/etc/motd"
             /                                   Q               A                                       3                                vi      T           3                                                P                                                               W

                 G       >               3                                                                                `




history                          C Shell                     B                                           \                                                                        "            ^       b       '                   9                                   `                           '

                         1                                           B                                                                                                                     B                   9               F                                                                   '




             % set history = 40


             9                       C Shell                                     B                               40                                                                                                                                    9                       `

                                                         z   Z               C                                                    r       D                                                    y                   A                                       3                   &                   b

                             +




ignoreeof    UNIX                                b                                                                            C       -      Control-C Control-Z                                                                                                            &          b

                                                         +                                                                            Control-D                  \                     t                                                                               @   " EOF, End
             Of File                                                         B                       3                        a                login UNIX                                                                                                  @                                       $

                             9           $       *                                                   N                                        Q                                                    ^                   W               A                                   $                       \End
             Of File"                                                                            9            $                                                                                                                            @                                   1                       $

                                                 A               9                           $               t        t                               $                                            \logout"                            ^           b

             UNIX                                        \Control-D"                                                                       UNIX                                                ]       -                                                                       8       E               H

                                         0                                   T           0                                        M                               l       p                                                        T                                                           b   d   y

             h               -       b               ignoreeof ignore eof                                                                             E               EOF                          9



             % set ignoreeof


                                                 \Control-D          "             \ignoreeof"        \Control-                                                           '

             D"                  $                        Use \logout" to logout.                  \Control-D"                                                                                                                             3                   #

              \EOF"                                logout                     \Control-D"
                     A                                                 \Control-D"           \Control-D"
                                                                                                 T                                0                                                                                        T

             $                           |           \ignoreeof"
                                                         '



             % unset ignoreeof


             9                                               '




noclobber    G                                                               0       '                                            K                           0                                        j       n                                   A



             % man cat > file1                                                                           #                    E    man catF                                                                w                   file1


             b       ^       b                           0                               le1                                                      D       3                                j           n                       M                                                               0   '

             Q   ?                       A               .   h                       b                            P                                                       H                                    A               b           9               )                               |



             % set noclobber

                                                                                                                                      59
4.2.          (Prede ned Variables)                                                                                                                                                                   Chapter 4.                                                   $           C Shell

                   1                                                  3                                           0       '       `                   A                               0   '                j   n                       B       D       3                                    |

                   0            |                                     j           n                               v                                           /                               \   j       (    : File exists."
                   0       '             j    n               B       D           3



                   !       \ignoreeof"                    A                                                                               T                               H       T                    *                   B       D       3               j       n

               |



               % unset noclobber


               9                              '



                   b       `        \noclobber"                               1                                                                           |                       9           1                            \unset noclobber"
               T                                 j   E        9       g                   0           '                           `                           1                                            3                              \ "          0       '               r        t

                                        \ "                   |



               % man cat                 >! file1


 lec           9                                 |   3                j           n       (           C           `                                                   (                                    G                                   C                               |

                   q       A    9                             C                                       -                   j       (                                           A                   b



               % ls -la
               -rw-r--r--                    1       robin                                                33054                       Jul                 18          15:05                   csh.tex
               -rw-r--r--                    1       robin                                                 2851                       Jul                 18          08:59                   freeware.tex
               -rw-r--r--                    1       robin                                                 6372                       Jul                 18          08:59                   history.tex
               -rw-r--r--                    1       robin                                                14191                       Jul                 18          15:43                   inout.tex
               -rw-r--r--                    1       robin                                                 8145                       Jul                 18          08:59                   internet.tex
               -rw-r--r--                    1       robin                                                38978                       Jul                 18          15:36                   intro.tex
               -rw-r--r--                    1       robin                                                  625                       Jul                 18          08:59                   k-home.tex
               -rw-r--r--                    1       robin                                                 1067                       May                 27          11:29                   main.tex


               9           j    n                                                                         <ESC>                                               <ESC>"                                                                       j           n                       (

                                                                                          C
                                                                                                                          1
               % more c<ESC> (8                                           y               E           more csh.texF )
               % vi inte<ESC> (8                                          y               E           vi internet.texF )
               % cat m<ESC>   (8                                          y               E           cat main.texF )


                                                              A                                               in<ESC>                                                 P                   I                    inout.tex internet.tex
               T               intro.tex                          <ESC>"                                                  R                                   .                   C Shell                  3   h                                       P                   E   T

                           j    n




                       9                 &            ?                               b                               3                       j       n                   (       C               `                                                                    H

               A           \This is a FiLe NamE owned-by-John"                                                                                                                    .           j       (                            4       Q

               :                j   n                                                             R           j       (                           W                                               b            \ lec (Filename Com-
               pletion)"            9                                                                     b       9                   )                               .                                                G                           C                               <ESC>
                           |        q                 k       H       9           "           8                   A                                   C                                               C Shell                          -                                       j    n

               D           \        C            \     <ESC>                                                  |
                                                                                                                      2           A                                                       b                        j           n                               =                    C

               K                                     <ESC>"                                                                                       j       n       (       C



                                    3                UNIX                                                             \ lec"                      9                                                    |       0                   3                   G                            j       n

                           (    C                     |           E       T                   \                       "       (       C                                           1                                                                                                 G

                   C                         <ESC>                                            -                   3                               L                   path                    0                            E       T                                   j            f       A


  1    A            Sun OpwnWin                           cmdtool                             9                                                                                                       xterm
  2A       \Control-D"      ESC                           |       .       b       E       T                       j       (               I




                                                                                                                  60
Chapter 4.                                      $           C Shell                                                                                                                                4.3.               (           (alias)           a           (history)

                                        1           3                 HP                                              ^                    &                               \make f<ESC>" C Shell                                                -                   Q   &

                                        W                   \make oating"                                                                                                                       \ /bin" 3
                                                                                                                                                                                                   P                  3




status                                  9                                                                             '                                            '           N                                                                                            q   A

                                                                                      '                       9                                        W                               .       \status"               '               \0"                           ?

                                        '                   \1"                   A



                                        % date
                                        Sun Jul 23 11:26:51 CST 1995
                                        % echo $status
                                        0
                                        % datt
                                        datt: Command not found.
                                        % echo $status
                                        1


                                        9                                                                         ^                K                           3           C Shell script                         `                                                         \

                                                                  9           b       ^       b           W




        9                       f                                         '                                                   +            9                                               +           \alias" \history"                                                        Q

            +                                                         F                           (                               Environment Variable


4.3                     (           (alias)                           a                           (history)
\alias"                 \history" C Shell                                                                                 `            !       y                       Shell                              F                                    Bill Joy             3

            .   `   X       x       BSD
                                    C                         y                                                   UNIX                                                                                        Shell                                 K           9           4

    w                                       4                                             3           K                                            C       g                   .           &                                  L

                !                                   B         !                                                   3       5            :       :




4.3.1 Alias

\alias"
% alias moer more


9           1       \more"                      9                  \ " alias
                                                                          b        \moer"                     (                                                                    &               \moer"                 `                   \more"
                    1                       C                (\Command not found")                                                                     E       y       W               H       "                                          C                     1       9

alias                                                   A



%   alias               ll ls -la
%   alias               m more
%   alias               dir "ls -la"
%   alias               lr "cd ~/homework/math/linear"
    3!              A           3                                                 G                       C                        \Control-D"                                 C Shell                        .           X       b   E   T             X   b           K




                                                                                                                                               61
4.3.                 (       (alias)                      a               (history)                                                                                                                                                                               Chapter 4.                                           $           C Shell

9            1           &            \ll"        `                                                       \ls -la"                                         \m"                    `                                             \more"                                &                           \ls -la" \more"
9                                                         ?               Y                                                                               C Shell                                                                   \dir"                                                 @        j         \ls -
la"              E   y            Y       DOS                                         1                       9                                                                   {                   |           .           DOS UNIX                                                        E        T       3           R           |

                                      3                   !                                                           6           .                               !                           M                                                                                                                                |           \lr"
                     \ /homework/math/linear"                                                                                             9                                           8                       y       G               1               cdpath                              alias            ?



         X       |                                1                   \alias"                             |                                           L                                                       }




4.3.2 History

history C Shell                                                                                                                                               ^                           3           G                   1               '                       prede ned variable                                                   `

    \set history = 40"                                                                                    C Shell                                 1                       B                                                                   40                              D       R                                    |       _   r

X    |     \history"                                              9                                   `                                           :                                                                           =                                                                    G

i    r                                                                                                                                `                                                                               J                       Z   C                                                                                i   r

G                                             r                                                               history                                                             $                               9                                   +                                        r                   history
)    b                            #                                                                   |                                                               s       y       3                                       C       0                   9                                r

     C                            @                       $                                                               .                       ?       ?           :                                                               |                   %                       R                        a

             b                        h                           $           UNIX                                                            b                           @                   1           L                                               g                       3       .                                            X    X

                         T                    \                   b               F       -           I                               g                                       A                   9                           M                                               A            A                                       X   |

                                      Q                                       >                   >




4.3.3                         M       A




     3                   :    :       3           C Shell                                     b                                           M




                                                              \ "                (Home directory)                                                                                                                 b                       \ "                 r   `

                                                              A               \ "                             r                               #                                                                       (       C       `

                                          A


                                          % cat ~John/.cshrc


                                                                      .       \John"                          9                                                           \.cshrc"
.                                                 G           9                               (                               8                       y                           \pwd"                       9                                                                                                    5       (path)
..                                                                                    G       9                                                       \                               "                       (




$HOME                                             \ "                 !       L




$bage                                                                         L                                   (                                       bage                                                                    |           L                   }       b                                                3




-                                         9                           r                                           P                                           \1-9" "a-z"                                                                          A


                                          % rm file 1-9]


                                                      l       *               le1, le2, le3, ..., le9                                                                                             A                       b       9           j                               A            P                               j       n        D

                                          3                   ^       n                                                                               b                           p                           t           &                       P                       ^   b                    j       n               D       3




                                                                                                                                                                                      62
Chapter 4.        $           C Shell                                                                                                                                                                 4.3.                 (       (alias)                         a               (history)

                                          A                                           C           P                       P                                           A                                            &                                   l       *               le1, le2,
                  le5, le6, le7                                       T                   A


              % rm file 1-2,5-7]
                          T

              % rm file 1,2,5,6,7]
                          T

              % rm file 1,2,5-7]


              9                       b                           8



                      E     le1, le2, le3
                              y                                                                               9                   3       j       (               b               9       C       -                                        (                                       j   n

                      \-" \ "                                                                     |                   b




              9                   r               <       g                               T           9                   C       -                               DOS         -               9                                    ?                   L                       A


              % cp ab* ~/TMP
              % cp ab*cd ~/TMP
              % cp *cd* ~/TMP


                             \ ab                   "        \ /TMP"
                                                                  |            \ab",                                              X       b       j           n                                                                    9

              \ab.kk", \abcd", \ab-ab", \ab cd"
                               \ ab              cd               "    \ /TMP"
                                                                          |                                                           v       |                                       X       b       j        n                                                                       9

                       \abcd", \abbb.cd", \ab-cd", \ab cd"
                                 \          cd             "      \ /TMP"         (           C                       b                                   X       b       j    n                                                                               9

                \cd", \.cd.mm", \abmmcdpp", \ab cd"              UNIX                                                                                                                                  3                                                                   |           j   (

                                   \ab cd"                                                                                        9                       j       (           b                   }            (       C                                           |                   #

                      |       b       C           -                                       |


              % touch ^Ewhat? ^E                                                                      Control-E                                                               shift-6-shift-E
              % ls -la *what*
                  ....
              % rm -i ^Ewhat? ^E                                                                      Control-E                                                               shift-6-shift-E


              9                                   z                                                       UNIX                                j       (               \




              9                   r               <       g                               C           -                           A


              % cp ??cd?                              /TMP


                   \zzcde", \a-cdb", \2.cdm", \cd"                                                                                                                9           j       n                        cd              G           b                       C       -                   b

                            \ /TMP"                                                                               9                                                                                                                                            -                           \cd",
              \cd.mm", \abmmcdpp"              \*cd*"                                                     9                   4               y                                                            )       \??cd?"                             !       }




              3           C Shell     /    \ " \            "(history)        r                                                       /       7       a                                                                                        r                       \
                               "              f   \ls -la"
                                                      A                                                                                                                   :   j       n           z                                    j           n       H       9

                             \.c"
                              :               j       n                                                       ^           :       z                                       Q           |                                g       \ls -la *.c"                                        :

                      |        \!! *.c"       \!!" == \ls -la"            3       9                                                                                                                                                    `                       9       a



                      G            history               404          \!!"                    |           B                   t                                                                                                    \                               "                           39
                                          6                   r \history" D                                                                                   |                                                    9                                           :       J               a       z


  4:    set history = xx                  xx              9       K




                                                                                                                                      63
4.3.   (   (alias)       a               (history)                                                                                   Chapter 4.                    $       C Shell

                     (history list)                                    :                             ( )                                             i   r                     A

                     3                    G


                 % cc -g -o proc conf.h proc.c f1.c f2.c f3.c -lm -lX11


                 Q                                      f1.c               3           compile               P       g                   |       :       history       0           i

                 r


                 % history
                       ...
                     17 cp proc.c proc.c.bak
                     18 more f1.c
                     19 more f2.c
                     20 cc -g -o proc conf.h proc.c f1.c f2.c f3.c -lm -lX11
                     21 ls -la *.c *.h
                     22 vi f1.c
                 % !20      r   a   r D




                 9                   \!20"                \cc -g -o proc conf.h proc.c f1.c f2.c f3.c -lm -lX11"
                                     |    f                                    a            |   6    Q   9       K       "           |       6       9   K   `             |

                 9   K                    C       :::

!-1                                                                                G                             \!!"        !   L




!-2              G                                                                                   A


                 % history
                     78 cxtk24 csh
                     79 set prompt = "<Is it true ?> "
                     80 echo "hello"
                     81 so
                     82 h
                     83 pwd
                     84 ls -la
                     85 more csh.tex
                     86 more test.cst
                     87 vi verb
                 % !-2


                 \!-2"           8            y         86     r                   \more test.cst"
!mo              a           z                                     t                   |        mo                       :


                 % history
                     78 cxtk24 csh
                     79 set prompt = "<Is it true ?> "
                     80 echo "hello"
                     81 so
                     82 h
                     83 pwd
                     84 ls -la
                     85 more csh.tex
                     86 more test.cst
                     87 vi verb
                 % !mo

                                                                                           64
Chapter 4.       $   C Shell                                                                                                                   4.3.                   (       (alias)                 a         (history)

             |   9        a           z                                86          r       (\more test.cst")                                        \!mo"
!?xyz?       a       z                                             t                                b    \xyz"       9       C                            :



             % history
                 78 cxtk24 csh
                 79 set prompt = "<Is it true ?> "
                 80 echo "hello"
                 81 so
                 82 h
                 83 pwd
                 84 ls -la
                 85 more csh.tex
                 86 more test.cst
                 87 vi verb
             % !?csh?


             |   9        a           z                                85          r       (\more csh.tex")                                         \!?csh?"
!78          a       z                                            78   r                                                 \cxtk24 csh"
^            9            r   &                                    \modi er"                                                                                                                                         C       f

             A   1                                            9



             % cat file1 file2 file3 file44 file5 file6 file7 > file8


                                                  .           le1 le2                                    le3 le4                     :::        le7           =       #       W                   j       n              le8
                                      C                         \ le4"                      W           \ le44"          9                                4
             H                9       `                            |                   ^        .         44    4    W



             % ^44^4


             9                                                1                                                          .                                    \44"                    W       \4"
:s           G                            1               |            ^                        G                                A                                            a           z

                                                  G                                                                                                   b           ]                                           \:s"   9       J

                        \s" \search & replace"                                                                               |                                    \cc -g ......."
             .   \conf.h" \conf.c"            W                                                                      9



             % !20:s/.h/.c


                     |                                                     1           3   a             z                                     20     r                                               .

                 \.h"         W   \.c"
                              9                                                j       E                                     \.h"          ?                      A               b                   |              J       9

                     \g" \s"      3                   G                        \:gs"                         :   !                              A                         .       X   b           \proc"                 K

             W   \prog"
             % !20:gs/proc/prog


             .           proc     3           J                        C                                                 g                 v                                      *   X       b               \proc"         X

             |       6                                I            \proc"                                                             3                                                       .               \.h"       b

                     g        X       |               |                  \s" \gs"              T                 K                   \g" \global"                                             I




                                                                                                        65
4.3.   (   (alias)       a               (history)                                                                                                                                               Chapter 4.                                          $       C Shell

                 A   r       \ "                                         z                                                                               C                                       1                               |               a           z

                                                             J                                                                                   A                                                           z                                                       C

                                             |                                               1                       '       b                           3       a               z                           _   r               26
                             26 diff ./hw.2                                                  ~/homework/math/linear/hw.1
                               ( 0      1                                                                2              )


                             3                                   \ /homework/math/linear/hw.1"                                                                                                                   Q               |                                   2

                 9



                 % lpr ~/homework/math/linear/hw.1


                     A                                       3   +                       \:"                 a                                                                                       .                                   C                   B

                     3       a


                 % lpr !26:2
                                 T

                 % lpr !26:$


                 \!26:2"                      26             \ 2 "
                                                                 a               z                       _       r                                                                                       C                                                                `

                           0                             0
                                                         R       \di "                       1                                                   _           r                       X       |                                               0 \./hw.2"
                         1 \ /homework/math/linear/hw.1"       2                                                                                                                                                                         b            \  }       T

                 t   " \ "           L           9                               L               C       -                                                                   C



                                          \$ "                       \               J                                       9                       r                                                                   t                               "   C

                 A      \!26:$"             26        \          "   a               z               _           r                                               t                               C               |       h                       1                        _

                 r    2                   8      \   E     "       \^"       b                                       r                                               C                                                       |       9               _   r           26
                     1    \!26:^"  \./hw.2"                                                                          9           C



                     A                                                   a               z                                                   C                           |               P                                               A

                     a               z               _       r   26                                                              j       n



                 % lpr !26:1-2
                             T

                 % lpr !26:1-$
                             T

                 % lpr !26:^-$
                             T

                 % lpr !26:*


                 \*"                     I                                                   \$ " \^"                                        )           9               9               y       \regular expression"                                                     D

                     P                       3       9                                                                               3                   b                               a                           +                   b                           \

                             |       0       8       n       h                       .




!$               G                                                                   t                                   C               | \cc -g -o                                     :::     "                                               1                        \-
                 lX11" \cat ......"                                                                                          J           \ le8"
                 % ls file* unix.txt
                 file1        file2                                                                                      file3                                                   unix.txt
                 % ls -la !$
                 -rw------- 1 KMJNS                                                                                      320 Jul                         8 16:23 unix.txt


                 .           9                               s                           @                       \!$" \!!:$"                                                 \!-1:$"                                                         B                           \!!"
                             \   G                                   "
                                                                                                                         66
Chapter 4.       $       C Shell                                                                                                                                                                               4.3.                         (           (alias)                                 a                       (history)

!            G                                                         X       b                                                                                                                   |       \cc -g -o : : : "                                                                                                    1

                             \-g -o : : : "                        9


             % ls file* unix.txt
             file1        file2                                                                                                            file3                                                           unix.txt
             % ls -la !*
             -rw------   1 KMJNS                                                                                                           102                     Jul              8          12:02                    file1
             -rw------   1 KMJNS                                                                                                           102                     Jul              8          12:02                    file2
             -rw------   1 KMJNS                                                                                                           102                     Jul              8          12:02                    file3
             -rw------- 1 KMJNS                                                                                                            320                     Jul              8          16:23                    unix.txt


t                             ]            0           '               Output Redirect                                                                                                                                                  command                                                                                             K

                             monitor                                                                                                                                   P       3   /                       b       `                                                                9             output
                              W                        f    background
                                                               A                                                                                                                   P                                                output                                                      message
                         .    9                output message                                                                                      /           R                   b                       X        X           :               9               `                                    \ "|                           t




             % my_program > message


             A       h                     my program                                                              X           b                                                       3           message                              9                   j           n                                                       f       A   G

                             \cat          .... > file8                                                    "                                                                           cat         9                                            .                       le                  /                           show                3

                 K                         \ \ t                       |       .                                   show                                3               K                                           0                                                    le
t   &                          0                                   0               3               G                   a                                                   UNIX                                                             (standard input)
                 (standard output)                                                                                     @                                   b                                                                        H         \         "(standard                              0

             error, stderr)                                    G               a                       B       1                                                               C                                                                                                                                    0                       #

                      ?                                                9                                                               :
             % ls -la /etc/*rc* /etc/ABCDEFG > message
             /etc/ABCDEFG not found


                         &             ^ : \/etc/ABCDEFG"
                                               b           s                           M                       2           ]                                                                                            9                   j           n                       D           3                       X       |

             /     \/etc/ABCDEFG not found"              ?          \ "                                                                                                                                                     :           :       b                           t                           r                               b

                     M                   \ "   G                           1                               b                               t                           r                                                            K                                                                   T                                   0

                 \message"        ?        \/etc/ABCDEFG not found"
                                                       9               j                                                       b                                                                                                                                    9               C                                           ?(
                         \message"
                         T         3     ?)                                                9                   j



                     ^     \ls -la /etc/*rc* /etc/ABCDEFG"
                                   A                                                                                                                                                                            9                                           b                   @

                                 \message"                         w                                                                       9                       j                                                                                                                        q                       ^       b

                     \/etc/ABCDEFG"
                         y                                                                                 9                       j           n                   D       3               C       W                        P                               W                               X           |                               ^   b

             X



                         \/etc/ABCDEFG not found"                                                                                                              #                       ?           \       "                0           G       >                                   \
             0   "                 \       "                                                                                       X       |               ^       b                   0         \message"                                              9                   j       n           !
                         @        \       "9                               0           G           >                                                   w                                       \           "                0                   H                                                   X                       \
                              0 "          H      \                3                                                                                                                              "H                                                                                            K




                     X   |                                                         P                                                                                       s                                                                                0           G       >                                   w                       K

                         A                 =           9                       0               G       >                                                                                       K       G                                                T           .       X           b                                           (
                                                                                                                   0           G           >                                           b               ^                )               K       w                                                       j           n           `

                 \>"                                       .                                       E                                                                                                                                    E                               \               0           G           >           "           ^   b

                                   \   E           }       "                   D                                   \                   0           G          ">    \>&"                                       9                            r                                                       \                   0       "           E

                                                            (stdout)                               C                                           0           (stderr)                                                             .                   K                                                       K

                 !
                                                                                                                                           67
4.3.   (   (alias)       a               (history)                                                                                                                                                                         Chapter 4.                                                      $       C Shell

                                     f                                     9                                                                                       ?       b               F       :
                 %   ls -la ~/.cshrc no-such-file > only-list
                 %   ls -la ~/.cshrc no-such-file > only-list &
                 %   ls -la ~/.cshrc no-such-file >& list-and-error
                 %   (ls -la ~/.cshrc no-such-file > only-list) >& only-error


                 f                        &                                                                           j       n                    z                   6                                               E   y                                                                                   b

                     Q                                            t                                                           &                        \(" \)"                                                                                         R                       W

                     I       5            Q                       \>&                 only-error                                       "           E       9                               R                                                                   b



                                                                                                                              s            G                   1                                           K                                           .                                       D       R

                     b       `            &                                                                                                                                    K                       W           &                                                   #               =

                             n       T                =               D                               K           z                                                (                                                                   H           9               ^               `       )       b           ^       b

                 ]                   |        .           9                                                       *               ?                Q       b                                               .                                                                                               j       n       :
                 /dev/null
                   /dev/null                                                                                                      j        n               1                       j       n                               A   1                        \ "        A                           X       b

                 0           9            j           n                                           K                                            P               P                       .                                                               \only-list"                                                     j

                 n           W       \/dev/null"                                                                                       g               f                                                                                           !
s                                    ]                0           '                   Input Redirect                                                       !                                                       |           0           '                   f       A                                       mail
                                                                                      \mail somedoby"                                                                                                                      mail                                                *               Q                       X

                                                      |                               ?            letter /                   w    3                                   9           j       n                           Q                       #



                 % mail somebody < letter


                     ?                                                                        K                                                                                            B           \ "     s                           |                   W               j       n




L                9                   r    \                               "                   .                                   program                                          background                                                                      A



                 % xterm &


                                                      3                   C Shell                                         \remembered pattern"                                                                     9                       b           F                   {   N

                             9                        9           1                   |                   A                        .               UNIX

^Z               G               1            \ "     L                           r                       |           .           program                                         background run                                                                                                                       P

                 T                                B           3                                           A                            .               w                       background        \Control-Z" \bg"                                                                                  C

                     \background"                                                                                                                  3               P                       \Control-Z"                                                                                                         #

                     \ "                              *           r                                           .                                                        P                       R     \Stopped"         Q                                   :                                                           C

                                                                           P                  B                                                    #               A                  \bg"                                 9                                                                                           .

                                                                              P                                   background                                                                                           Q           A                                                   ?

                                          P                                                                                                                                        K                                               P                                                   9       `                       |

                     \jobs"                                                :          :                   3           3       9            $                                       P       K                       %                       V                           A



                 % jobs
                  1] -                   Stopped                                                                                                   man cat
                  2] +                   Stopped                                                                                                   vi k
                  3]                     Running                                                                                                   xterm
                  4]                     Stopped                                                                                                   cat *tex


                     9                                    :                               3           9                   $                                3       b                                                   R                                   P                                               \man
                 cat"        9                                                                ^           \man"                                                                                                                    \vi k"                                                  ^       b                   @




                                                                                                                                               68
Chapter 4.       $       C Shell                                                                                                                                                                      4.3.                (       (alias)                  a           (history)

                                 R                                                                       \xterm"                              9                           P                       3                                                                X       |               V

                 \Running"                                                                                           ^                                                R                                            \job"
                             :               3           \ 1]"                                       b               \-"                  r               \ 2]"                                       b           \+"              r                           1               2       r

                             P               f                                                               R                                                    A                                       R                                T           8                           9

             8                       P               b           \+"                         r                       R                                                                            9               b   \-"              r           1   r               P       4   3       8

                             \+"                     r                           X       |                       A               \bg"                         9                                               .       ^                                        9               .

                     K                                                               .                                        \+"                     r               J                                               K                                                Q

                 \-"             r                                           W                               \+"                  r               4       3       t       G                                                                        r               \job"           L

             W     \-"                   r                                               1                   \+"                  r                               5                           \-"                 r                        5                   ^       b           r

                                             A                                       #                                                e                                                                   |                   3   \ "                                      r       D



             % bg %1


             9                                                       1   r                       P                       3    e



                         \bg"            8       D                \fg"       b                                                                                                                                        R                    T           3       e

             P           J  \            G               " foreground
                         \ "                                     e                                       t                    _       r                                           |                               ]   P




                                                                                 \ %"                        T               \%+"                 T       \%%"                K                                       b       \+"          r           e                                   X

                                                             |                   \%-"                                                                 T




                     C                                       3           \ "                                         #                                C                                                   X       b   e                                        |               C

                                                                                                                     9                1               \   C               "                                       T   9            C                           A




                                                             % %v
                                                             T

                                                             % fg %v


                                                                                 .               2       r                            \vi k"                      J                   \   G                   "
                         C                                   3           \ "                                         #                \ "                     Q                           #                           C                                        X       b       e

                                                                                                     b               C                                        job                             A


                                                             % bg %?tex


                                                                                 .               4       r                            \cat *tex"                                      J                   \
                                                                                                                                                                                                          e           "
                     b   `                           .                                                           R                            P       T               B       3                           e                                P   l       *                           |



             % kill %2


             9           .       2       r               P           l       *                                                                                                        9                   \2"                      \jobs"              :                                   r

             D



                     A               .       3                           e                                                                    P                               K           G       (foreground)                                     :
             % fg %3


             9                                   .          background       3                                                                                3       r                   P                               foreground
                                     3               \fg" \bg"                                           `               r    D               G                       \ "                             r




                                                                                                                                  69
4.3.   (   (alias)        a           (history)                                                                                                                                                                                                                    Chapter 4.                                                              $           C Shell

                      \kill"                                              r           D                |           b                                                                           \kill    "      r       D                           r           D                                               \ "                     r               r   D

                       process id      \ps"                                                                                :                                                                     \kill % "                     r           D                               r       D                       b      \ "                                  r       r

                 D          job number      \jobs"                                                                                                                         :                                                                       @                                           .                                       e

                              P                K          b                               8       E                                                r           D                       process id                                                                                          |                       ps                          :

                 X    |                   l       *                   `                               \kill PID"                                           9                           ]                                               |                                                           9                   r           D                   \jobs"
                              :                                                                                        !                                       l                       ]                   b



                      !                                   b           `                       b                                                    process      \kill"                                                                                         ^                                   l       *                   9       `                       |

                                          \-9"            9                               4           : \kill -9                                       " \kill -9 % "
                                                                                                                                                       r           D                   T                                               r           D




                 9                        5                                                                                r                                   3                           \           M                                       M           "                                                   `




                 % cd                              cp .cshrc .cshrc.backup                                                                                                                                 cp .login .login.backup


                 9                3       !                                                                                                                                                                                                        W                                                       5                       g

                                               !          3                                           history                                              K                           F           C




                                  9                   UNIX                                                                         a                                                   |                       \               ,           W                       "                                       1

                                                                  \                                                    \



                 % ps -auxww | grep verilog


                 G                                    \ps -auxww"                                                                          :                           G                                       G                                                               V                       b                                   process             3

                 run                  9                                                                    b                                                                                                                                                   b           n               verilog                                             ]

                              |               \ "
                                              t               .                   ps                                                               0           '                                                   D           j                                       X       X           :                       X           X       0

                 \pipe"                               |       6           *                                        D           j                                                               .                                                                                                       X                                     \
                   "                  \                                          \ "                                                                       \                       #                                                                                   9                                                                   \ "     .

                      r       G                                                   \ "                                                              r                                                                                               X           |                                                                   \ps -auxww"
                                                          b               verilog                                                                                                      8



                   \more"                                                     Y           #                                                                                                                        A                       \ls -la more"                                                                               DOS \dir
                 /p"              b       !




n                                 (               G                                                   \                (           " alias                                                                                                                     |                               ?                                       (                       b

                 `                                \               `           "                                                    alias                                           f           A                                   &                                               L           l           *       j           n       `

                      (inquire)                                                   @       -                                                                                    l           *               |               0           l               j           n                   X           |           b           \alias rm rm -
                 i"   9                       3                               \.cshrc"                                                     X           |               N           g                           \rm"                                        l           j       n           `                               K        \y"    /                   T

                      \n"             9                                                           l        j           n           `                       9                                               1   i                                   b           `                       9                   1                                   C               f

                 A    1           y       5                           y           @                            l           *                                                                                                           j           n                                   J

                                  /                \y"                                        i                            9           `                                                   |       .       \rm"                                        (                       \               `           "                       *           \nrm"
                              3                G                                                      \n"                                      |                                                                                   b                       \n"                                                         (               ^       b

                              (



                                                  ]                               J                    \yes"                                               9                           F                                   |           C                       G           1                       \pipe"                                      A               b

                      J                                               '                           \garbage"                                                                                                        I           l               *                                                      \alias rm rm -i"
                                                                                                                                                                                                                                                                                                       b

                 9                             (                                                                                       K                       |



                 % \rm -rf garbage
                 % yes | rm -r garbage


                                                                              C Shell                                          /                       \rm"                                                                                                    \garbage"                                           |                                       K   l

                                                                                 C Shell                                                                \yes"                                  9                                                                    \rm -r garbage"
                                                                                                                                                                                                                                                                       X




                                                                                                                                                       70
Chapter 4.                                              $        C Shell                                                                                                      4.4.            (                           (Environment Variables)

                                                                 .                                        9           \yes or no"                                         G           p               9               /                                                           b

                                                                                  \yes"                       %           K                                           /           \y"
                                                            ?                                                     b \no"                                              ^   b       \no"    9                                                           A

                                                        \no"                  /                           1        \yes no"                                   |



                                                    % yes no | rm -r garbage


                                                        @                 \yes"       9                                                   3       \yes"                           C       P                   g                                   :       9



                                                    % yes 'I Love UNIX'


                                                                          \Control-C"                                     *           \yes"                                               J                                           \yes"

        f                                               '                 K       3               +                                                                                   |                                   L                                               A



% set number = 1


            L                                               \number"                                                          T



%set beta = "Beta"


            L                                                   \beta"                                \Beta"                  9               C                                                                               :

9           '       W       %                                     \echo"                                      A



% echo $beta
Beta                                                             /




                    3           C Shell                              &                \$                  (               "                                               /



        T                                       |               \set"                         :       X       b           B                       \set"                       L                               b                           :               X

                                            L       E




                        %               `               m                                 L       9                                   D   3                                           b                                   )                               Shell Script
`           3                   Shell programming                                         `                                       6                                                                                           P       +                           P   m

                                               C Shell                                                                                                }                       P                       b                       +                                   C   +

                                                            `                 A       .                                                           `                       \/usr/local/lib/a/b/c"                                          9                                   C

            |                               L



% set pp = "/usr/local/lib/a/b/c"


9                                           -               |            \$ pp"                           \/usr/local/lib/a/b/c"                                                                                                  C



                l       +                       3           C Shell                                                           r           a               z                                                                                                   3       C Shell
                    2               !                                         F               (                           Environment Variable                                                            T               \   (               "


4.4                             (                                (Environment Variables)
    :       :       3                       \.cshrc" \.login"        T                            9                   j       n                           b       ^   b                           /               }       P                   9




                                                                                                                                                  71
4.4.                (                   (Environment Variables)                                                                                                                                                                                                                                 Chapter 4.                                                          $           C Shell

                                                        setenv ABCD "What-is-This:And-This"


                                L           (                                           (environment variable)                                                                                                                                  \ABCD"                                          S       r       /                       Z   C                                       1

}   P           ^       b                               L



        \       (                   "                                               \   8       E           T                               P       " \                                         "                                   9                   X\                          8       E       T                           P           "                                       P   3

        `               m           b                           S                                                       A       3           G                   a                                                                       3           C Shell                                                C Shell
            C Shell                                                                                        /bin/csh
                                                                                                            P                                                                                                                               0                           X                                  PATH                                                                     9

    (                           S       C Shell                                     0                  PATH                                                     9                           (                                           '                           D                       \set path = ...... " \
#   "       W                                               1                                   \set path = ...... "                                                                                                                    PATH                        9                           (                                                       '               ?               3

9               PATH                9                           (                                                                                                       P                   `                       K



                                                    G                   1                       \               '                               " C Shell prede ned variables                                                                                                                                   9                           1               \               (               "
    environment variables                                                                               b                               !                                                           -                           3       y                               '                                               3                                   L                           $

    Shell                   b                   P                   G           C           y                   \ " $                                               (                                                               P                   J                                       L                           (                                                   $       |

C   3                   $                                       @                                           P                   9                       1                           P                   Q                                       C Shell                                 $                                               F                               &

    C                   L           '                                                               (                               J                   K                                                   C                                       L                       (                                                                               L                   '

        \set"                           )           !


                                                        setenv ENVVAR string


                                (                               ^           b                   r                       9                           \set"                                                                                   2       ]



                    &                   :           :       b                                           (                                                   B                                       Q                                                   L           ?                                           1                                                       \       1   \

\                               (                                                               |           C                                       '                                       5                               n




HOME                    9                   (                                                                                                                                                               5           (                                       A                   \/home/ds1/johnsmith"
                        3               login                   `                                                               \/etc/passwd"                                                           9                       j                                       0                         \HOME"                        Q                   .                                   9

                                    (                           '           W                                                                       H                   9                           (                                                       (                                           '                                       E                               G       1

                                                        '                                                   \home"                                              G                                           '                               `       1                               \home" \home"                                                           9                       '

                                            \HOME"                                      9                               (                                                   #       '




PATH                    9                   (                 \path"                                        G                                                                   9                                   '                                                           3                                                           login               `

                                    L       \PATH" \/bin:/usr/bin"                  W                                                                                                                                           L       \path"                          `                   \PATH"                                                                  W               path
                                    5                                                                                       %                               b                           !                       /                                                                       !                                                                                               (

                                                                                                                        $       |                                       P                   X           |                                                           \path"                          9                           '                                           \PATH"
                        u                                                                                   3                                   Shell                                                                       P                   ^                      \path"                                   X                       L

                                \PATH"                                                                  |           !                   b        \path"                                             G                       !                           |           0                                                                                   H                       9       &

                                    B       1                               9       g           X                       \   3                      Shell                                                                                    P       "                           9                                                               f           z                           '

                                    3                   3         Shell                                                                         |                   '                                                       '                                               \abc"                           Q                       3                       Shell
                                            g               C Shell                                 :           :           3       9                   \               $       "               b           ^           b           \abc"                   9


                        % set abc = "1234"                                                                                  ------>                                             L                             abc W 1234
                        % echo $abc                                                                                         ------>                                     :                                   abc
                        1234                                                                                                ------>                                             Q                           1234
                        % /bin/csh                                                                                          ------>                                                                 g         C Shell                                                                                               G       9                   $

                                                                                                                                                                                                                $                                       9                               $       /

                        % echo $abc                                                                                         ------>                                     :       :       3                       $                                   abc                                                     L

                                                                                                                            ------>                                     ^       b                   L                               $           ^       b                   Y                   $                       abc
                        % exit                                                                                              ------>                                                                 $                       /                           $

                        % echo $abc                                                                                         ------>                                             :                                       abc                 3                   $

                        1234                                                                                                ------>                                     3               $                                   b                   L                   ^

    5   SunOS                   9




                                                                                                                                                                                            72
Chapter 4.                                              $           C Shell                                                                                                                                                                                 4.4.                         (                           (Environment Variables)

                                                                                                                                                        |           :                                   \set"                       X                                    '                               \abc"                           ^   b       3                       P

                        (/bin/csh)                                                                                              |           !                           9                                                                       J                                                                                            W



                        % setenv abc "1234"


                                        J           G               a                                               '                                           9                   a                                                           (                                                                                        !




TERM                                                '                                   ^       l           V                       A                                                                   ^                                   #           #                x           ^                                                                           h           '

                        ?                           A                                   D                                           r                               ^                                                                                            '                                   |                                       \vi" \more" T                   9

                                                                ^               V       b                   6           n                                           P           `                                                           K                                                                                                                A           '

                                                    9           '   W



                        % setenv TERM vt100


                        \vt100"                                             I       5                           K           b                       L                                           ^                       V
                                                                                                                                                                                                                                    6

LOGNAME                                         b       C Shell \LOGNAME"                                                                                                                           b                       J                       \USER"                                       9                                                                       user-
                        name                                  login                                                         `                                                                               (                                        \HOME"                                                                  3           r                           `

                                                    \/etc/passwd"                                                                                           ]                                               '                       ?




        ?                       3               T                                           (                                                       %                                                                   K                       b                    F   F                       F                                                               (           K

b               default                                         '               /                                                                                                                       m                                               L                   \HOME"
                                                                                                                                                                                                                                                                                 A                                                   9               (

/                                                                                          \ "                                                                      f           A                           USER                                    T                    LOGNAME                                                     9               (


/                                                                                   username                                                                                F                       b                                                        b                           user
                                                                                                                                                                                                                                                                                         '                                                                               UNIX
            %               K               E           N               9                           (                                   \                   D           3                                                                                                        PATH HOME USER                                                                              b

default                                         b           `                                                                               PATH                                                                N                                                    8                                   P       w                   2   ]                           X   |   N

                        (                               PATH                                                                                    .       h                                   6                                               L



                                                        PATH HOME USER                                                                                                                                                                                  b                        c           9                           L               g                               |

    L                                       (                                                                                                   H                   X                                                               H                   b                                                                                H                           8

    m               b                           (                                   B                               X           |                               !                                                                   L                                    (                                                           cxterm                              Z

xterm                           |       3                                                   Z                               m                                                       1                           Z           C                                                ]                                                       3   #           2       ]       X   |

m                                   (                           (HZINPUTDIR)                                                                                                            Z                                               3           %                2       ]



                        1               W                           UNIX                                                                                                .                           P                                                            G       K           w                               P           /               ?                       1   E

            UNIX                                    .               (                                   3                       P           /                   f           A                                       1                       HZINPUTDIR                                                           9                   C                               cxterm
                        -                                           P           /                       i               HZINPUTDIR                                                                  9                       C                        HZINPUTDIR
                                                                                                                                                                                                                                                             y                           .                                                                   L   W

                                                                .               Z                                       w                                                                   {                                                            F                                                   x           C               }

|                           .           HZINPUTDIR                                              9                                   (                                                                                           |                                                                            _                       (re-compile cxterm
                        P                   9                   f               b               P



        t       h                                                           |                                   ?                                                                   L                                                           (                                    f           A       1                                   N       g

            5       T   (                           j                                           |                                                       (                                                                       Q                                                |                           \$                  (               "
    G               1                       '



                                                                                    L                                       G                                                                               H                                   (                        (           C                                                       |                       T       P

    B




        3       \.cshrc"                        /                                                   :                                           ?                                                       (                                               9                        1



    6!                                                  ^               V                   G               w           3       \/etc/ttytype"                                                                                                  \/etc/termcap"                                       b                       6           n               A       b

                |       @           ~                           b   F                           3       h                           D




                                                                                                                                                                                                    73
4.4.                (               (Environment Variables)                                                                                                                                                                                     Chapter 4.                                                  $           C Shell

MANPATH                                 9                   (                                   L          manual pages
                                                                                                                    manpage                                                                 5               manpage
                                                            UNIX                            a      \man       "       (on-line help)                                                        ]

                                                                      UNIX                    \/usr/man/man?"         \?"                   a                                       ]               w       3

                                                     1, 2, 3, : : : , l, n                        (nro /tro )                                                                       ]   K                                   }           P                                                           Z                               v

                                            w       3               !        \cat" \cp" manpage       \/usr/man/man1"       A                                                                                                                       w           3                                                                   9

                                                    \kill",\link"          \/usr/man/man2"                  w       3                                                                                   9                               A                                                                                       P

                                        v                      manpage                                                                                          P               ]       -                       T                                           a                                   9               &

                                        UNIX                a                                       ]                   w           3                                           n                               -



                                            f      manpage (tro /nro format) \my program.1"
                                                        A       1                                                                                                                                                                                                                                       w           3                   \
                                         /man/man1"        \.?"        \man/man?"                                                                                               w                                                                   9                                                                   .

                                        MANPATH                                 9                           (                                               L       W



                                        % setenv                            MANPATH /usr/man:$HOME/man/man1


                                                    |
                                                                    7       man                     9                                                                   MANPATH                                             0               manpage
LD LIBRARY PATH                                                         &                               C program                                       K                                       I       5               program                                         K                       call                    !

                                        function                                                        library                                                         .           h               A               N                               P                               j       K     \ "                   b

                                        library                                                                                 X           |           UNIX                                .                                                       library                     (   C       w                           P       /

                                        Q           3                     library link
                                                                            P                                   `                               .                                                                                                                       j                                       9                   F

                                            \Shared Library" LD LIBRARY PATH                                                                                                                                                                L                                           P   `

                                        library                             5 program   5                       X           |           b       `




                                        ld.so: warning: /usr/lib/libc.so.1.6 has older revision than expected 8


                                          message                                                       .                   3               link                        b                           (                               E           )               `                                               A

                                        warning                         J                   |                                                       P   )           |                                                           J                       u                           v



                                        ld.so: libc.so.101: not found


                                            G       >                                                                       compile                             P




EDITOR                                  9                   (                                       '                                       _                                                           '                       \vi"                                            |                   '                       A



                                        % setenv EDITOR /usr/openwin/bin/textedit


XAPPLRESDIR                                             9                   (                                               '                                               0           X Window                                            P                   \resource"                                  A



                                        % setenv XAPPLRESDIR /usr/lib/X11/app-defaults:/users/X11/app-defaults


NNTPSERVER                                                              b           n                                               L           news server                                                                                     8           n       Z




        ?                            1              9                   T                   .                           3               C Shell                                                                                     *                       K       1                                   @               ^       b

9                                                                               s                                   )           b                   y                                       ?                                   ?           {           N                                               |                       3   t

            a   X                               h




        3                   a       &                                                                                           \.cshrc" \.login"           C                                                   |       :           :           A                           G                                           F           3

9               j       n       /


    7           \.cshrc"            T 3     $                       9




                                                                                                                                                            74
Chapter 4.   $   C Shell        4.4.   (       (Environment Variables)

                                       I   .   .       T        F       H   4

                                                       ?    ?   b   X


                                                               from Chaos
                                                           by James Gleick




                           75
4.4.   (   (Environment Variables)        Chapter 4.   $   C Shell




                                     76
Chapter 5

:        :                   @       j




3   9        a   &       @   j           @           j   n   \.cshrc" \.login"                     G       a   1           D

@        @   C       1           G           a   X            /            |           t       +                   \   @       "   j

n        \.logout"           :   \.cshrc"    j               t    G            r   D       1       ]   -           3

j   n




5.1 One Example - .cshrc
     1   ############################################################
     2   #   Other settings of 'setenv' are all in ~/.login         #
     3   ############################################################
     4   setenv OPENWINHOME /usr/openwin #define OpenWindows' Home directory
     5   setenv XAPPLRESDIR '/usr/lib/X11/app-defaults:/usr/local/X11R5/lib/X11/app-defaults'
     6   setenv SHELL /bin/csh
     7
     8   # Everytime the files listed in the following got changed, you will be notified.
     9   # By default, your mailbox, the SA' memo and bulletin board are the ones you
    10   # should be informed
    11
    12   set mail = ( /usr/spool/mail/`whoami` /usr/local/lib/adm/messages )
    13   umask 002
    14   set nobeep
    15   set nonomatch # man csh to learn more details about 'nonomatch'
    16   # set the filename self-explaining feature. i.e Enable filename completion.
    17   set filec
    18
    19   set path = (   $OPENWINHOME/bin $OPENWINHOME/bin/xview $OPENWINHOME/lib \
    20                $OPENWINHOME/lib/X11 \
    21                $OPUS_HOME/bin \
    22                /usr/local/X11R5/bin \
    23                /bin /usr/bin /usr/ucb /usr/5bin /etc \
    24            /usr/etc /usr/games /usr/local/bin ~/bin . )
    25   set path = ($path /usr/tran/sparc/bin $OPENWINHOME/demo)
    26   #########################################################################

                                                                      77
5.1. One Example - .cshrc                              Chapter 5.   :   :   @   j




 27   #set noclobber # Redirect output protection
 28   # set prompt="`hostname` `pwd`]\!> "
 29
 30   set   prompt="`hostname`/\!> "
 31   set   history=40
 32   set   savehist=40
 33   set   ignoreeof
 34   set   time=100
 35
 36   alias a alias
 37   a bye exit
 38   a ls 'ls -F'
 39   a rm 'rm -i'
 40   a mv 'mv -i'
 41   a cp 'cp -i'
 42   a vt100 'setenv TERM vt100'
 43   a moer more
 44   date
 45   pwd
 46
 47   a h history
 48   a md mkdir
 49   #a cd 'cd \!*    pwd'
 50
 51
 52
 53   # a cd 'cd \!*   set prompt="`hostname` `pwd`]\\!> "'
 54   a lo logout
 55   a mail /usr/ucb/mail
 56   #a cprv 'hz2ps -big -hf hku-ch 10 1 -hbm 16 -ls 12 -v \!* |lpr'
 57   #a cpr 'hz2ps -big -hf hku-ch 10 1 -hbm 16 -ls 12 \!* |lpr'
 58
 59   a tin "setenv EDITOR celvis /usr/local/bin/tin"
 60   a dir "ls -laF \!* | more"
 61   a elm "setenv EDITOR vi /usr/local/bin/elm"
 62   a ll 'ls -la \!* | more'
 63   a df '/bin/df | more'
 64   #######################################################################
 65   if (`uname` == "HP-UX") then
 66       set console_user = `w | grep console | grep -v grep | cut -f1 -d' '`
 67       echo Local user is : $console_user
 68       if ( $console_user != `whoami` ) then
 69            echo "Remote login ... not on console"
 70            #echo Machine Type is HP
 71            #echo setting up proper stty modes
 72            stty intr ^C
 73            stty erase "^?"
 74            stty susp ^Z/^Y
 75            stty kill ^U
 76            #stty werase ^W # By defaults, no need to set again
 77            stty stop ^S/^Q
 78            stty eof ^D
 79       else
 80            echo Login on Locally ...

                                         78
Chapter 5.                       :   :               @           j                                                                                                                                   5.1. One Example - .cshrc

 81                         endif
 82
 83                         unset autologout
 84                         alias a alias
 85                         a df 'bdf | more'
 86                         a psf 'ps -ef'
 87                         a psl 'ps -el'
 88                         a rsh remsh
 89                         a pstat swapinfo -m
 90
 91                         set path = (. /etc /usr/etc /bin /usr/bin /bin/posix \
 92                                 /usr/contrib/bin /usr/bin/X11 \
 93                                  /usr/vue/bin /usr/local/bin /usr/local/X11R5/bin ~/bin )
 94
 95         else # uname == SunOS
 96
 97                         limit coredumpsize 5m
 98
 99         endif
100         ##################################################################
101         # Do I have my personal command aliases and other SHELL settings ?
102         # You can change the name anyway, e.g My_Own_Cshrc --> ~/My-My
103         #######################################################################
104
105         if ( -e ~/My_Own_Cshrc ) then
106         #   echo "Found my own setting files ... sourcing....."
107             source ~/My_Own_Cshrc # source ~/My-My ? if you want ..
108         endif
109         ###########################################################################


        9                                                |       \#"             r                                           1           3       C Shell                         |       \#"         r                        K                   \
    "
                    4 5              5               L                   \OPENWINHOME" \XAPPLRESDIR"                                                                                     9                        (                       3               5
                        &                L                           (                       m     \ "                   |                   5   (           `                                   5            9       5




             6         \SHELL"   L                                   9                       (                           9           (                                                                   $                b               P

A           mail, vi, ex                             .           &                                           `                                           P                                       :       \SHELL"      9               (

            X                            $                                                           P               9                       '               \/bin/csh"                                     C Shell
                    7                                                |       \#"         r                                               K

b                       2    ]                                               T                       |                           K           |



                :            12                  T
                                                                                                                 1

                    13                       1                                   b       ^                                                           j   n       `                               .                J   '           W   %               E

            j       n                                        '                               666                                 X   b               K           \                       j       n           A                                        '

                    777                      X       b                               K           \



        G                                    |                   \chmod"                                                                     j   n           J               P                       3        :      13
                    E    y                       j           n                   A                       J                           666 777                             9           '                        \umask" user mask
                             9                               )           (               L                                       C Shell                             J               n       *               mask                         |   9

    1           ^   :            a




                                                                                                                                     79
5.1. One Example - .cshrc                                                                                                                                                                                                                                Chapter 5.                                      :       :                   @       j




                 1        \umask 002" \002"                                                                                                                                                   |   G         \chmod"                                                              |                       P               5           '

                 !       group                                                                                                    n           T               J                           X       |       \002"                                                                                      C       !           group                               K

n   T       J                        E                                                        J                   T                       n               *           \ "             9               J                 B                                \2"             |                                                                       \010"
9     \1" \rwx"      3                                            E                   \w"                                                                                                                 .        \w"                                                                       J                               .                               T

    \666"                X       |                    3                   W           \664"
                     6                                    6                                       6                       <--->                                           110                             110                   110
umask                0                                    0                                       2                       <--->                                           000                             000                   010
    W                6                                    6                                       4                       <--->                                           110                             110                   100


                 1           X           b                                                        j           n                                                           j       n           J            K                    W           \664"                       \666"    &                                   X       b

                             j       n            J                   K                                   W       \775"                                                   &       \777"                                     |                                        \umask"                                         D                       j       n

            J                        X                                                    C                                           X               m




                 14                                                                                       #           #                                   f           A       1           3                   le completion                                                              `               A                   C Shell                 ^       0

    |           match                     j           n           (       C                                                                                                                   |           \set nobeep"                                               T                                           3            \vi"           `

H   9            <ESC>"                      4        Q           P                                                                           #               #                           z                         \set nobeep"
                                                                                                                                                                                                                            |




                15                                                                                3           ^       0                                       |               match                            j   n    (       C           `                                1       \no match"

% set nonomatch
% ls Z????????
Z???????? not found
% unset nonomatch
% ls Z????????
No match.


:                !



                17           T



         19        \path"                                 '                                                                                                               3       9                                    \$ OPENWINHOME"                                                                                                   G                   L

    \/usr/openwin"                                                        3           9                                                           O                       \ "                                      9                                     ^       b                   @                                                                               .

          \path"
            '                                     H           9                               X           |       5                                                                                       24                    t                                                                            \               "           X       |       ^       b       \
    "   3



                                                                          A                       3               path                                                \."                                                                                            j                                           1                   f       A

3   \cd /tmp"                                 Q                               :           :           3                               b                           %               j           n                                             \ls"             9                                   X               Q            D      T

    ^                        3       \/tmp"                                           b                       j           n       l               V                       \executable"                                      j           n                         \ls"                       /                       \\rm                -rf                     "
                    \ls"                                              Q       .                                   X           b           j           n                               l                             .               3                            \."             w       3           path
                 \ls"    `                   \                                3                           G       "                               0           \ls"                                     0                                             \\rm -rf                                        "                                                       H

R                                    \." path                                                             J       *                                                           9                                                                     \./run"                                                                  G               5

P   \run"                                                                                                     \run"                                                   9               f                       ]    -            2           ]



        25                                            W                                           \path"                                                                          _                                                             3    9                           \$ path"                                                                    L

    \path" 19-24
                30                       '                                                                r                                   :           `hostname`9                                                                           3 C Shell                                            &                           `           r

                                                                                  X           |           \set ABC = `hostname`"                                                                                                                   \ABC"
                                                                                                                                                                                                                                                    .                                    9                                           '               ^

(   C                                                                 r                       \             \`hostname`"                                                                               .                    w                   \ABC"                                        9                                       |       z

            \`"
% hostname                                                                                        hostname

                                                                                                                                                                                                      80
Chapter 5.                                  :       :                           @        j                                                                                                                                                                                  5.1. One Example - .cshrc

roxy
% `hostname`                                                                                                                          roxy
roxy: Command not found.


3   `hostname`                                                                   !                                                a                       _               r         N                                                                                   9            \!"             X

                            %                   3       \!"             G                                                                                         E           a                 .                   A                           \!>"                                            \>"
                                                                                                                                                                                                                                                                                                 .                           W       a        _    r

T                           3           a               z                            0                               &                                                             \>"      9                           r                                                            .       \!>"                    W               0    a

    3       G                                   E       a                   .                            r                                            B                            30                   9                                           L                                                        r                       W



% set prompt="`hostname`/\!> "
roxy/23>Z


                    31                  T                                    1




        |       G       1                   a               z                            K                   j           E            g           r                               login                                                         1               9            a               z               3                                UNIX
            g               r                                       `                            K                                                A                                 .       9           g               a                                       g                                                                        32        9

                    \savehist"                                                                                                    .           9           g                                         D       R                       w               \ /.history"                                                     9                        g

login           `                                                       9                j           n                   .            g                       a                     8       /                           W           B       b               a



                    33
                                $                           3                                                                                                                                                               C               9



% cat *.ps *.log
1.1u 0.3s 0:15 10%


            %               b       `                   b       9                   G        >                                                b       `                       Q         ^       b



                    34                                  \time"                                                                    !                                                                             `                               9      \ "
                                                                                                                                                                                                                                                        K               J                `                                                9

            |                                                       9                                C                                                                                                                  1.1         J               \user time" 0.3                                                      J               \system
time" 15                                J               \real time"                                                                   G                       4                                             4                   y   5                                                                                9               `             @

                                    G                                                                                    34                                                                                                     `                               100          J       `                                       9

                                                G               K           y            100                 J                                            6



                    36                              L                                   \a"                              (                            @           j                     \alias"
                    37                      43                                      T                                |



        B               G                   1                           3                                login                            UNIX                                `                                                                                 \ /.cshrc"                                       X       |       3            44
        45                                                                                                                    3           &               login                                                                 G       X       3                            5                           3           ^                    `




        59            \alias"                           3                                                                                                                                                                   \EDITOR"                                             L                                                   P

    \ "             5                                                                    X        |                                       \tin"                       9                             `                           \setenv EDITOR celvis"                                                                                    Q

     \/usr/local/bin/tin"
        60                                                  E           a                G                       1                        L       \prompt"                              `                                   9                                       L                            \dir"                               (

    \dir"                                   `                                                                                 @                     \ls -laF                                        !* | more                               "                       62                               9\!*"                                %

                                    \       G                                            X       b                            "                                   2                                 9                   alias                                                                1




% dir file* unix.txt
    2                               a                       C Shell history

                                                                                                                                                                                        81
5.2. One Example - .login                                                                                                                                                                                                                      Chapter 5.                                                  :       :                       @    j




    `                       \ le unix.txt"                                                                           \   G                                       X        b                       "                       Q                        @           j




% ls -laF file* unix.txt | more


                    65                           99                                                                          f                           \                                C Shell                             P                                                            \uname"                                 9

\           X                                                            \HP-UX"                                     T                       \SunOS"                                                  ^                                                b                       &                       !               5                             !       '

                                                         9                                                                                               3        \                                                   (               \                    T                       q       A                                       m

    P                                                        97                              \limit coredumpsize 5m"                                                                                                                               C Shell3                                            A               b               coredump              s

    `                           core                                                         3  5 Mega Byte                                                                                                       9                        T                       6                                                           b       n   core              1

                    :               a       t



                    105                          108                                                                                 P                       :        :                               b                                   '                                j           n                   m               3       @            `    \

                    '                       9                        \ /My Own Cshrc"             \ /.cshrc"                                                                  |       .                                                                                                                    I                       .                     w   3

            }                       j       n                        ]       -   \ /My Own Cshrc"        i                           .                                                                                                /                    J                   w



                                        \source"                         9                                                                                   \                    "             C Shell Script                                                                             3                           a                   1

                        UNIX                         `                                                q              A               X                        $                   '                      \ "                  (                    :                                                       \.cshrc"                        9         j   n

      \ "       :   \ "`.cshrc"                                                                                                      9               1                    \                   " \source"                                               9                                                       9                                     3       ?

    \.cshrc" \.login"                                                            j       n                                                                                                -   I                           '                                    A                                   3                           \.cshrc"
           \alias m more"
                    (        \.cshrc"                                                                     3                                                                   9                                                                                                                b           '               9                    (        .

            3                                                $                   `                                               :                           \.cshrc"                                     3                                                                                                    q                           L

                                                         \source /.cshrc"                                                                                             @       f                                           \.cshrc"                                                                                                                           X

|                                   |            9                                   3                       !               T                           '                            !                   (                           3                                9                                                                                 \

b   ^       b       \ /My Own Cshrc"                                                                 9                   j       n            A                   b                                       \                       " 4


5.2 One Example - .login
                    :                           \.login"                     9                   j           n                               P                                x                                   Sun                                                                                          3                                    login
                            q       A                                                C                                                                   3                                                                                                                         logout                              &                             :   :

b   :               U               2       ]                                                                                >                                                                    T                                                                                        |                                                             T

3   :                               a                                /                           @            ~              9                           1                                                            %               .        \setenv"                                                                K                        I    5       w

3   \.login"                                         \.cshrc"
        9               .                       \setenv"                                             (                                   6       '                            g               Q                                                                        F                       |                       N                                 $
    5           X       |       .                    w\.login"   3                                                                                                g                                                   Q               .        9                   \setenv : : : "                                             w       3       \.cshrc"
            |                                            9                                                               N                                        $                   9           \setenv"                                                 (                                                                               '             g

b   F       9       h                       i



    1       setenv EXINIT 'set sh=/bin/csh sw=4 ai report=2' # Set default EX/VI mode
    2       setenv NNTPSERVER 140.96.200.1      # This is for news reader 'tin'
    3
    4       ############### This line sets for X's resources files    ###############
    5       setenv XAPPLRESDIR '/usr/lib/X11/app-defaults:/usr/local/X11R5/lib/X11/app-defaults'
    6       ############### This line sets for X's resources files    ###############
    7
    8       ############### This line sets your man-pages search path   #############
    9       setenv MANPATH ${OPENWINHOME}/man:/usr/man:/usr/local/man:/usr/local/X11R5/man
    3b                  unix                             C Shell                             ^       b           9                           '
    4t                                  P                    C Shell Programming                                                                             +                            C   +                                   3                    a                                   >                                                         P

A                   9                            P       &               :           U                            &          \                           a                            /                       :               T                    |       :                   U
    5                                   a




                                                                                                                                                                                  82
Chapter 5.    :   :   @   j                                  5.2. One Example - .login

 10   ############### This line sets your man-pages search path   #############
 11
 12   ########## This line sets your shared libraries search path   ###########
 13   setenv LD_LIBRARY_PATH .:/usr/local/X11R5/lib:${OPENWINHOME}/lib:/usr/lib:/usr/lib/X11
 14   ########## This line sets your shared libraries search path   ###########
 15
 16   #########################################################################
 17   #   Printer setting                          #
 18   #########################################################################
 19   setenv PSLIBDIR /usr/tran/sparc/lib
 20   setenv TROFF ptroff
 21   setenv TCAT "lpr"
 22   setenv PRINTER lp
 23
 24   #############################################################
 25   #   The following sets for Chinese X-Terminal: cxterm       #
 26   #############################################################
 27   setenv CXTERM_FONTPATH '/usr/local/lib/cxterm_fonts'
 28   setenv FONTPATH "$OPENWINHOME/lib/fonts:$CXTERM_FONTPATH"
 29   setenv HZINPUTDIR '/usr/local/lib/cxterm_dict/citnf' # cxterm_NewFace
 30   #############################################
 31   #   End of setenv's                         #
 32   #############################################
 33
 34   #######################################################################
 35
 36   if ($TERM != "sun") then
 37   eval `tset -sQ -m dialup:?vt100 -m switch:?vt100 -m dumb:?vt100 $TERM`
 38   endif
 39
 40   # If possible, start the windows system.   Give user a chance to bail out
 41
 42   #==================================
 43
 44   set myname = `hostname`
 45   setenv XSERVER $myname
 46   setenv XCLIENT $myname
 47
 48   #==================================
 49   # Automatically 'setenv TERM'
 50   set noglob
 51   eval `tset -sQ`
 52   set glob
 53   if ($TERM == "network" || $TERM == "dialup") then
 54
 55      setenv TERM vt100
 56      unsetenv TERMCAP
 57
 58   endif
 59
 60   echo "Terminal type is $TERM"
 61   #==================================
 62
 63   echo ""

                                            83
5.2. One Example - .login                               Chapter 5.   :   :   @   j




 64   if ( `tty` == "/dev/console" && $TERM == "sun" ) then
 65       click -n    # click -n turns off key click
 66   endif
 67
 68   cd
 69   echo ""
 70
 71   if ( `tty` != "/dev/console" || $TERM != "sun" ) then
 72       set prompt="`hostname`/\!> "
 73       exit    # leave user at regular C shell prompt
 74   endif
 75
 76
 77   set mychoice=op
 78   #############################################################################
 79   switch( $mychoice )
 80   case    op:
 81       unset mychoice
 82       echo "starting X-Windows .... "
 83       echo " "
 84       echo " "
 85       echo " "
 86       echo "Which Window Manager ?"
 87       echo "Choose 1: for Open Look Virtual Window Manager (olvwm)"
 88       echo "Choose 2: for Motif Window Manager (mwm)"
 89       echo "Choose 3: for Open Look Window Manager (olwm)"
 90       echo -n "Choice: (1,2,3) "
 91
 92
 93      set window_manager = $<
 94      switch ($window_manager)
 95      case 3:
 96
 97           # Use Open Look Window Manager
 98          /bin/sed "s olwm olwm -3 " ~/xinitrc.template.no_kill > ~/.xinitrc
 99           clear
100           echo " "
101           echo " "
102           echo " "
103           echo " "
104           echo "Starting Open Look Window Manager, please wait ..."
105           echo " "
106           echo " "
107           echo " "
108           /usr/5bin/banner " O p e n"
109           echo " "
110           echo " "
111           /usr/5bin/banner " L o o k"
112           breaksw
113      case 1:
114
115             # Use Open Look Virtual Window Manager
116             /bin/sed "s olwm olvwm " ~/xinitrc.template.no_kill > ~/.xinitrc
117             clear

                                          84
Chapter 5.   :   :   @   j                                5.2. One Example - .login

118          echo " "
119          echo " "
120          echo " "
121          echo " "
122          echo "Starting Open Look Virtual Window Manager, please wait ..."
123          echo " "
124          echo " "
125          echo " "
126          /usr/5bin/banner " O p e n"
127          echo " "
128          /usr/5bin/banner " L O O K"
129          echo ""
130          /usr/5bin/banner " Virtual"
131          breaksw
132
133
134     default:
135          /bin/sed "s olwm mwm " ~/xinitrc.template.no_kill > ~/.xinitrc
136          clear
137          echo " "
138          echo " "
139          echo " "
140          echo "Starting Motif Window Manager, please wait ..."
141          echo " "
142          echo " "
143          echo " "
144          echo " "
145          echo " "
146
147          /usr/5bin/banner "M o t i f "
148          breaksw
149     endsw
150
151     #sleep 3
152
153     op
154     clear_colormap # get rid of annoying colourmap bug
155     clear       # get rid of annoying cursor rectangle
156     logout      # logout after leaving windows system
157     breaksw
158     #
159
160
161 case    sunview:
162 default:
163     unset mychoice
164     echo -n "starting SunView (Control-C to interrupt)"
165     sleep 3
166     # default sunview background looks best with pastels
167     sunview -b 200 255 200 -background $HOME/cartoon.sun
168     clear       # get rid of annoying cursor rectangle
169     # logout        # logout after leaving windows system
170     breaksw
171     #

                                       85
5.3. One Example - .logout                                                                                                                                                                                                           Chapter 5.                                          :       :                   @       j




172
173 endsw




5.3 One Example - .logout
3   9           G                                                            ^                           9                   j           n                   .                                   c                           \.logout"                               9                   j       n                   \.login"
?   8   D                                   3                                            UNIX                        `                                                   3                                   G           X                                                           |

\.logout"                                       :
# This is .logout file
clear
echo " "
echo " "

echo        -n "`whoami` logging out at : "
date        | tee ~/.lastlog
echo        " "
echo        " "
echo        " "




                        |                                                    :           :               T                       .                   "                               \ /.logout"                                             :       :           3                               UNIX                            g               \
    /.lastlog"                      b           %




5.4                 b                                                            t               ?




        G               c                   &                            |       s                           UNIX                                                                &                                                                       .           h

                X               S                                            UNIX                    @       3                       H       {                                                               3                                                                           \   0               2           "           L

        3               \       D           T       }        X           `                                   K           B           k       "           8                           1                   UNIX                                        /                       |                       W           W       P           '




-           b                                        j       n                           core

                    core                9                j       n                                                                                                                                   T       P                   *       `                                   b               core (core dump)
            9               j       n           B                                            P               *                       `                               X   b                   V           3   B       7                   /                                       X       |                       9           B

                                debug                                P                                   X       |           A                                                                           C       P           0       l     core dump
                            3     debug                              `                           A           Sun                                                 dbxtool                                                                   core                          9               j                                                   3

                    *                                                    P                   |       -               "           >                   0             bug                   A                       m                       debug                                   P                                   l       *

                                                                                 y               core            9                       (       C                                                   b   a                                                   3       \                                   \           B       7

                            3                       IC                                                                                               (magnetic core)                                                                             P                                           0               1           `

                            3                                *               `                       .                                               ]           B                                   X   X   0                           0                                               I       *               M                   B   7

            K                                   0                IC                                                                                      \core"              9               (       C                                                                                           |                           9

                    0                                                                b       P           core                                                    9                                       ;   <                           9                           |




            % find ~ -name core -print


                                                                                                                                                                             86
Chapter 5.                :       :               @       j                                                                                                                                                        5.4.            b                                               t       ?




-             M           j       n   (       C




                                              s                                                   b                                M                   j       n       (       C                       ^       b                                                                           3

                      `               T                   y           P                   0            T                           y                   p       B       k       "       8                           D                                   3                                   l       l

          *           9           j   n           q       A   B                       |   \-"                              t           9                           A               \-rwx--x--x"                                        j           n           (       C       |    \-"
          l               @       3   \rm"            9                                   manpage                                              K                                                                                                                   Y               \man"
                          E                   |           y                           W                                FAQ6                                3           SunOS                                       #                                                                    rm
          4




          OPTIONS
               -                          Treat the following arguments as filenames `-' so                                                                                                                                                            that
                                          you can specify filenames starting with a minus.


                                                  i



          % rm - -rwx--x--x


              Q           b                   ]                       A



          % rm ./-rwx--x--x


              u                               M           (   C                       b   ?                        ]



          % rm -i *


                                  \-i"            4                                                                                        l               $                               l                           j       n       `       /                       \y"                         K   /

            \n"               T                   \Control-C"                                 c       \rm"                                                 A               =       9               a                                               ?                   \i-node num-
          ber"            l



          % ls -i *                                                                                                                                                -i                  4               0           j       n                       i-node                              r   D

          % find . -inum 1234 -ok rm '{}' \                                                                                                                                                    l       *           j

                  T

          % find . -inum 1234 -ok mv '{}' normal_name \                                                                                                                                        T                   (




          1234                            l                       j       n               i-node               r       D                       i-node                                  UNIX                                                                        j       n               ]

              &           N                                   J       r    D                               y                   ?                   $       2               C           UNIX                                                Q                                       ?               !
                                                                      l       *       j   n       (        |       \."                                         j       n       `                                           9                                               3                       UNIX
                          C       W   p       |   R                   l   p           :
          % \rm -rf ./.*


              #                   ?                                                   \*"                  \./.*" \./." \./.."     .                                                                                                       b           \-rf"                       4                   ^

          b   D       C               2                                       w                                                    =                   G       X       3               9                                                       l           *                   !               9

              4           0                   T   !!
                                  A                                                       C       -          \&" \|"   A                                                                   J               |                   E       a       \n"                         E       }

                                              (           \a&"                    j           (        \strange. le" :
          % mv a\& strange.file
    6   Frequently Asked Question

                                                                                                                                       87
5.4.     b                    t       ?                                                                                                                                                                               Chapter 5.                              :       :            @   j




-                b    H   9   C                       A                   .           N                                   C       \ "     5




                 \fold"       9                                                   A


         % fold -80 input > output


             .       input        9           j       n                   N                   C                                           80              I           5           5




-        A       .        man                                                     D       W                                           Text            j




         % man                    (           > ascii-file


         9            W                                   .                   9                                               j           n                                               b                                               C       -                       \more man- le"
         :       `        :                                                                   \vi man- le"                                            T                                                           ^                                   `                    |   s

             m        9                       C       -           `                   T                       l           *


         % man                    (           | col -b > ascii-file


         9                C   -                   \col -b"                                                            l           *                                                   A                                       #                           ^                    man
             |


         % man -t                             (




         A            J                       X                           \man le" \manpage le"                       T                                                                               |           ro                                      |


         % nroff -man file.man | more


             :        T


         % nroff -man file.man > file


         D                j   n




-        A       .        DOS         }       P               Z           C       j               W           UNIX                                }           P



             A            3           UNIX                            :                               Z           C           j                                   N                               t               K       b           \^M"                                 j   n

         3       DOS                                          |                                           ]                                               W               UNIX                                Z       C       j   :
         % cat dos_file | col -b > unix_file


         b           UNIX                                 A               SunOS                                       b                                   \dos2unix"                                                          7                       9


         % dos2unix dos_file > unix_file


-        UNIX         b       DOSKEY
                      9                                                                                                               DOS                                                                     Y               |   N               "

                              UNIX                                W       R           X       B                                       N                       Q           %                   ^           s                   #                           B       D



             9                            @       T                           W           \               $           b                           v                           DOSKEY       "                                                  .                       9                T   $

                 W        X       |               A                                                   9                                                                       $     \tcsh" \bash"                                                                     K    b   9

         Q       b                                                        J                                               |                   $               9                           UNIX                                        2       ]

    7E   T                \unix2dos"

                                                                                                                                                          88
Chapter 5.                   :       :                     @       j                                                                                                                                                                                                   5.4.                b                                               t       ?




               .                     p                 UNIX                                                        (       C                                               r   i                                                                                               3                                               &                       B   :

                                          s                                    (               C                       {           K                                                                   ?           B                           )           b                               UNIX                                                                (

           b        @    ~                                     &               |           D                                   T                                                           :       :




awk                  awk             9                                                                             .                                                                                                 \ "
                                                                                                                                                                                                                       @           3                                                                                                           P           9

                         P                                                             3               UNIX                                                >           >       b           (       Alfred Aho, Peter Weinberger,
                     Brian Kernighan Alfred Aho                                                                                                                                            egrep                Peter Weinberger
                                                                                                                                                                                                                           9                               P

                            lcomp Brian Kernighan                                                                                                                                  c           c   C   b           (  C                                +                   s                                                                       +       O   B

                     n \The C Programming Language"                                                                                                                                           \K&R" \K"            8
                     ditro eqn                                                 P



                                 ^  awk                                                                    (           C                        |      9                                                                           (




bi                   9                   P                                                                                 b                                                               X                                                                                                                           3                   K

                                                                               %                                   \bi "                                   q           A
                                                                                                                                                                                                                       9       '           Heidi Stettner                                                      O       J                   @       1           `

                     @                                         @       ~                                                               w                                   N       F               @                   .           l                                                                                                       K       .   p       W

                     5                                 9       w                           K           3                   -           X       *                           `                                                                John K. Foderaro10                                                                             W       9           P

                     `                                 ?       ?               (           C                                                       .   9           w                           (       C           \bi "                                                       9           w           5                                                   Heidi
                     Stettner                                                                                                  B       3           1993                    O       8           `               t                           O               15                                                                  h



                                               q       A                       :                                                           h                       1               \bi "                   #                                       x                           R                                               \compiler"
                                         v     J                       \B"                             3           .                   (               2                                       #                                       p                               n               (           C                   9                                       <

                     \   \Ph. Dog"
rc                                                             M                           %                                               !               C Shell                                     @                   j\.cshrc" \rc"
                                                                                                                                                                                                                                       n                                                                                                   9           %

                                     rc                                    \RunCommand"                                                                          1965
                                                                                                                                                                   \       3                                   O      MIT CTSS              \runcom"                                                                       b

                     ^                                  3                          j           n               /                                                                           v                       batch le               \runcom"                                 F                               `

                         \run commands"                                                                                                                                                UNIX                                                        9                   3                           j           n       /                           9

                         @         \rc"  j     n       K       |                                                                       A       \.cshrc"                                T                           3                                       ^       `                   @                   j       \/etc/rc"
C++                  C   +                                                                                     C++                                             `       3                           @                                           Bjarne Stroustrup                                                                   X       '                   X

                     |           (            C++                          .                       3            C              +                       b                                                       +                           3                  \++"
                                               C++                         (           C                                   9




rsh                                                                            \remote Shell"                                                                                                                          &                                                                   ^                                               `

                         P                                                      rsh     \rsh ccsun2 program-name"          A                                                                                                                                                               A                                               e               P

                                               #


                     % rsh ccsun2 program-name &
                                                                   T

                     % rsh ccsun2 "program-name &"


                     9                                         .                   rsh                                                                 P                   @                                   3       /                               ^                       Shell                                       X                   ]


                     % rsh ccsun2 -n "program-name >& /dev/null < /dev/null &"


       t            \.cshrc" \.login"                                                                                                                                                              \.rhosts"                                           j           n                           m                                                       G       1

                   \rlogin" \rsh"                                  `               |                                                           password                                                r                                               ^                           A                                           SA          ^       b   '

                         |           \         '                                       *                       "               ^                                   :                                           A                                       \ /.rhosts"
     8 \R"      Dennis Richie, unix                                                            x
     9b              bi  b   n                         9                   ]                                                                                                   unix FAQ                                                        3       9                                                                               @       @       |    Email
'     Heidi Stettner         bi          @ -       b   n                                                           @       P               .                   !                   P                 Email ?                                                   2           3       h
     10q    Heidi Stettner
               A                    Bill Joy                   1                                                           T                    b                                          John K. Foderaro                                                                    Franz Lisp

                                                                                                                                                                           89
5.4.       b               t   ?                                                          Chapter 5.    :   :    @   j




ccsun1
roxy
metaford
robbins


       9           ^               *       ^       9       ^       b   \rsh" \rlogin"
                                                                              T                 O   =   a   `    K   .   &

                       .       8       ^       w       .       A          ^       ?   b                     username
                   y   .   &                                             \rsh" \rlogin"         =   a           .            W

               0




                                                                                                            Time is linear
                                                                                                     Memory is a stranger
                                                                                                        History's for fools
                                                                                                Man is a tool in the hands
                                                                                               Of the great God Almighty
                                                                                             And they gave him command
                                                                                                   Of a nuclear submarine
                                                                                            And sent him back in search of
                                                                                                      The Garden of Eden
                                                                                                  from Amused To Death
                                                                                                         by Roger Waters




                                                               90
Chapter 6

Tour of Tools

9           a               3           G                           Ed. 2.4                                      C                                                             9       b                       UNIX                 P   K       .                       H   9       T       E        H

                                        .       T                   Q       M                                                 9           ?                                                9               a                            x                           9               @       3   ?

                                            |                   .                   #                                                         ^



                3                                   :::




6.1 V-eye
\To vi or not to vi, that is a question!"                                                                                                         9                   @    3                                                            UNIX                    `                               vi   9

  \         "   (               R               _                           >       I                p



                                &                   /       G                   1                                                         \vi"                                         3                   ?   ?       :        9           a                                   :
                                                                                                                                                                                                                                                                                        1

        \vi" \visual editor"                                                                                 9                                                                                     _                       Editor                       &           ^   b                       UNIX
    .              (Well                K                                       A                                        UNIX                                     .                                    y                    K               \vi"
                    &!)                                                             %                .                                            .                                        \vi"                UNIX                                                     default                 _

                           UNIX                                                                                  b       \vi"             9                   _                            %                     UNIX                   K                           .       |

F                       UNIX    K                                               N       ^       _                                                     v                                    |                                    1           &                   \vi"
        |               +                                       \vi"                                 I   5                                                                                                 9                                        E                   b                       1

g                                   K                           N                                        X           b    b       n           \vi"                                             (




6.1.1                               T                       "           8




b           1                       \       "   8               G                   (       t        |                                "                                            ?                   C           0            Back Space                          "               W

                Return                      "           |       C                           "       Space Bar                                                     .                9                   "                                        {           `                                   E


    \vi"                                                                    ESC             "                        ^            9           G                   (



        D               \vi"                                                                             \                P           "                   %                    \                   P       "                        3                       ]                               ]        `



    1A                              .                           P       n




                                                                                                                                                                      91
6.1. V-eye                                                                                                                                                                                                                                                            Chapter 6. Tour of Tools

                    3                             !                               P                        3           6                                                         P                   G                           X       k                            C                                            W

                         A                        k                   \a"             9               C                            A                             3       \                           "               P                               \a"                                      3               K            A

    3       \                "           P                    k         \a"                   9                C                                                     b           \a"                                                                      D       T



        3                                DOS                      _                                                                                          3       \                           "           P                           k                    N                       C                   K                            Z

C                                        D        j           n                   T                                                                                  `                                                           "                    W                               *                            m           #

N           "                                                         #       E



        \vi"                                                              z                        3                                    P                                                            b                   !               G            3                               ]       `               B            3

P           V            ^       b                            .               ?



        X       |                                                                                 <ESC> 9                                   "           ^                                                                                                                                             |       /        \           "
P                                3                                    P                             <ESC>"                                                               /               \                               "           P                                K

    y               K                             /                   \                       "        P




6.1.2 vi                                              P           b




                                 \vi"                         `                                           3            X                        \                        P           "               9       `                                       |        \                   "   j       n               /                A

l   *                                    .        \abc"                                       W       \ABC"                                      \                                               P           "                                        D                               \                       "                        E




6.1.3

            &            @       j                                    _                                j           n                :       :       \vi"                 9           b       9           p



% vi


9   `                    J               $                            \vi"            %                                                     :           t                \           b                   4       g           g                   \ "                                          g           g

                    ^    b               ]




        &                    Y                            <ESC>9                                  "                    @                /               \                    "           P                   Q                                                6                               9               ?        Y       Y

    :       "       8                                      <ESC>                                                                        i       9            "



        g       g                    3                    *                           ^                                    3                                             }                   9                   `          \vi"                 3                                            '           &

Z   a                                                         \   &                               "                                 3               \i"                                                                  \insert"                         P                   n           #                                C



                        \i"              `                                    3           \             "                      P            9               \i"      C                               \                       "                                                    C                   3                        \i"
                                                                                                       \vi"                                         \                "               P                           y                               P                                                                 C   K

    *                            H




        ?                                        \i"                                  ^                                                     ]                    K                   t                   g       g                   |                                b                                   0                B

                                                  M                                                                                <ESC>                                     Q                   #                               \:q!"                9                       |                           \vi"
            g



                        \i"                                                                   9                    Z       C                                             \return"                                "



I love UNIX.


    W               9            Z           C                                    *                        3           \UNIX ."                                                                                                      3       \                "           P                       3               <ESC>                -




                                                                                                                                                                             92
Chapter 6. Tour of Tools                                                                                                                                                                                                                                                                                                                                   6.1. V-eye

            K               |            /                   \                       "       P                                   s                       *                                           \."                                         9                                           g                                         `                                \."     9

C   -



        ?                       \i"                                                                              9                       C



and I hate vi


9   `                       s            \UNIX " \and"                                                           =               3                   R        \UNIXand"                                                              .                          \i"          3                                                                             P       `            *

    3       \."                                          #                                       Z           C                                   3           \."                         G                   X       |                                   \and"     \UNIX "                       3

3   \UNIX "                                                      \."                                         .                       ?                                                                   3                                                \UNIXand"                                                                        t                                        3

                                                                     }




        B                                    &                           P                       `                                               <ESC>                                       9       `                           *                                                   \vi" \i"
                        <ESC>                                    \                   "           P                       3           9                                   P                                                           |                               *                           A                     |                                           ]       '    "

    *                               ]    -                                                                   3                                                           O           G                   ^       b       ]               '           "               `                           \vi"                                      |                       *

             \H" \J" \K" \L"                                                                         9                                                           9                               "                   C       4                               3           J               "           8                                     \H"             3       t                    X

|                          \L"      *                                                                            3               t                                   X           |                                               *                                                                       \J"   J                                                       \K"
            HJKL                                 "           5                                                                                                               &                   ?           B



                Q               A                                                        |                   ]           '           "                                               *                                               ]           '       "                           |



                3                            *                           \UNIXand"                                                           2           ]                                           <ESC>                               @                           B                           \                 "               P               Q                       \H"          "

                                    \L"      "                                           *                                                                                                                                               \J" \K"                                         .                                     ]               b                                :

    *                                                                3       .       *                                           3           \UNIXand" \a"
                h               c                )           3    \ "                                    P                                               n                                                       \ "                                         P                   .                             3       \a"                     G

}                           \i"                                  \ "                             P                                                                       "                                       \UNIXand"                                                               5                                                 <ESC>                       /            \
    "           P



        ?                       E            E                                                       C                       b           Q                                                                                                                                       P                                                                 P               9                    9

    E       \vi"                                                                                                 9                       E           \vi"                    G           b



                /       7                                                                                                            ]                                               *                                                           ]                           .                                \i"
                                    Q                                0                                           <ESC>

                3                            .                               k                                   9                                       Z           C           D           R                                   \unix.txt"                                                               D                                                            <ESC>
Q             \:w unix.txt"                                                                                                              A       r                                                                               3               t                                                                         A           r               #

}           \unix.txt"                                   K                                   3           A           r                                               \w" \write"                                                                                                 \w          unix.txt                          "                               \   .       9            /

              unix.txt      "                        9               j           n




                }       1               \:"      A           r                       \vi"                                                                        P                       ?                           &       Y               -                           }                                     \vi"                        @       b                            P

                                                 b                   ed                  P                   |           A           r                       :                                               K                   ed                      P                   ed                  P       x                                                 j       n       /

    A                                                                '                       r                                                                                   &                           :               3                   ed                  P                           E                             3



        D               j       n                        3               \:q"                                                Q                       |                                   <ESC>                           <ESC>                                   G                   z       9                     3           ed                      P                       \q"
            \quit"                               9                                                   \vi"
        9               \vi"                             _                               B                                   \vi"                X           b                                   P                                                           \vi"                                Z       C             D           j       n                           \vi"
    B               \vi"                                                                     2

                                >            \i"                                                                                                     3           >


    2               D               ESC              "                                                               K                                       ^




                                                                                                                                                                                                 93
6.1. V-eye                                                                                                                                                                                                                                                                               Chapter 6. Tour of Tools

                        i                               \insert"                                                            3           *                                   G                                                   Z       C



                        a                               \append"                                                                    3           *                                                                                   Z       C



                        o                               \open"                                                          3           *                   X               3



                        O                               \Open"                                                              3       *                       X           3



                        I                               \Insert"                                                                3                               t           G                                                   }                                                Z       C



                        A                               \Append"                                                                        3                                   t                                                       Z       C



                        J                               \Joint"                                                                                                                 /                   #                                                                    1                        *                                  C       -




    9                                               3               Y



% vi unix.txt


                            !                                           3               3   \vi"                                                                                                                        j       n       (       C                                                 _                              B       D       3       j

n           A                       j       n               D       3                                           Q                               C                                                       j           n




                        \vi"                            :                                                   C           3                                                           K                       ]       b                           C                        j       n       (                        j    n                             C   -

            *                                       3                               C                                   Q                                   3           \                           "               P                       3                   \o"                  *                        ?             }            9

    B      \open a new line"
            #                                                                                                                                                                                                                                                                        |                                          \Learning vi
is a good thing."                                                                                <ESC>/                                                                                                     P                               \o"                  *                           ?                     }                             |

                            Q                       3                       `               <RETURN>"                                                                                                                                                                3                                P                    \o"   !



        ?                                                                               %                           E                       T                                               *                       3                                   K                                                     3                 <ESC>                Q

    \HJKL"                      T       ]       '       "                       *                           \good" \g"                                                          C                                                       *                                $                                ?     K J
?        H L                                                    T                                                                                       .                           \H" \L"                                     3                       "                t               \                \J" \K"                        =       3       R

                                                                                                                                                                                            W



                3               \O"         \O"                                                         9           `                               3           *                                                               9                                                            *                    3    t    G

                                 \Learning vi is a bad thing."                                                                                                  Q                               \ESC"                       /                                       P



                B                                                               3               >                                   \ "                                                     ^           b                                                        C                   3           \vi"                                    .           C   l

*                   .               @               C       p       /                               |                   #                               @                           C                                       C



              \bad" \good"
                '                                                               W                                                                           *                              \bad" \b"
                                                                                                                                                                                                3                                                       C                                    Q            3                      P                   Q

    \cw" Change Word        \bad"                                                                           s                                                               W           \ba$ "   \vi"                                                                3                           \bad"                                   *               #

        \good" \$ "      \bad"                                                                                                                                                      W    \good"                                         9       `                                        3                             P

                                                                        <ESC>/                                                              P



        OK                  A                                                       .                   delete                                                  3                       >



                        *                       3       \good" \g"                                                              \x"                                     |           l           *           \g"                                     *            X           3                                C                                  g

    l                               A                         5     l       *                                                   \5x"                                9                               "



        A                   \dd"                l       *           J                                                                                                   *                           X           3                                               l            *                                         g    l        2
    \2dd"             \dw"(delete word)     l       *                       C                                                                                                                           X                   \                       C       "                    b                                                               A

    \I" \love" \UNIX"        \      "                                                       K                   X                                                   C



        ?                                       9                                               @                               |                   W           X               b                   _                                                                                                                           \                "
                                                                                                                                                                                            94
Chapter 6. Tour of Tools                                                                                                                                                                                                                                                             6.1. V-eye

                dd                          l           *       *               X   3



                dw                          l           *       *               X   3                       C



                d2w                         l           *                       *       X   3                               C                   |                           2                   C



                4dd                         l           *               *           X   3                       |                           4
                dG                          l           *               *           X   3                       |                               I



                x                           l           *       *               X   3                       C



                3x                          l           *               *           X   3                       C                               |                       3                   C



                X                           l           *       *               X   3       G                   C



                3X                          l           *               *           X   3                       C                               |           G           3                   C



                u                           Undo                            /                           _               G                               V




                U                           3                   ^                                   G           /                       X       b           3       9                                           _




                                                            3                                               l   *                                   `               l           *                                       @           j           1           3            P                        bu er
/                   |                               \ "             /                       \p" paste                                           9                                               |           G                                           1



I love UNIX and I hate vi.
Learning vi is a bad thing.
Learning vi is a good thing.


    '               3           \d5w" \vi is a bad thing"                                                                       l           *                   Q                                                       \p"                         s           \vi is a bad thing"
9                   l       *        \ "    C                                   /                                           H                       3           *                                                       A                                   3    *               G

        \P"                             .           *                                   t                                   Q                               \P"             :           :                                                                        9                            _

    \cut and paste"
                                              \copy and paste"                                                                          l           *               C       b        bu er
                                                                                                                                                                                        w           3                           P                                /                        |        copy
                                                     bu er
                                                        P                                       /                                                           |           \copy" \vi"        \yank"                       3                           +                                         %

    \yank"                          ?             \yank" \ "                                    d                                                                       d       \yank out a tooth"
                                                                                                                                                                                    o

    \copy"                                  bu er                       /                           H           )           &                                                   +        \yank"                     Y                       %                                         &

                    B           &       9                   C                                                           |           B                               \yank" \vi"                     3



        3          \love UNIX"
                        '                                                                                           t                                                            \love" \l"             *                                                                Q                    \y2w"
    yank out 2 words        \love UNIX"                                         9   `                                                                                            bu er                          P                                       /            Q                             *

            t           \love UNIX"                                 w                                                   2       ]                                   \p" \P" \love UNIX"
                                                                                                                                                                                T



                .                               9       v       _




                yy                              T       \y1y" \1yy" yank out a line                                                                                                         *                       X   3                                       bu er        /



                y3y                             T       \3yy" yank out 3 lines                                                                                      3                                       *               X           3



                y4w                             yank out 4 words                                                                4                   C                           *                       X       3                           C



                p                               paste                               bu er                   /                       3           *




                                                                                                                                                        95
6.1. V-eye                                                                                                                                                                                                                                       Chapter 6. Tour of Tools

                        P                            Paste                           bu er                           /                       3           *                           G




    g       )       G                       \d"                                                                  _                                               n



        B                               Y                                        b                                           *                                       ]                                                                       9       !               HJKL                                 ^

    g                       C                       T           g                                            ]           P                                                                       8       r                       3           >                   "    >

                                                                                     M                                           C                           .           9                                   *




                        H                                               *                '



                        L                                               *                '



                        J                                               *                '



                        K                                               *                '



                        w                                               \w" \word"                                                                                                                       C                                       C



                        3w                                                                                           C                                                       C



                        b                                               \b" \backward"                                                                                                           G                       C                                   C



                        3b                                                               G                           C                                                       C



                        e                                               \end of word"                                                                                            *                   X       3       9               C       t                        C



                        Control-B                                       \backward"                                                                   ?



                        Control-F                                       \foreward"                                                               ?



                        G                                                    j           n   t



                        0                                                                                            }




                        $                                                                            t




        9                                                                                                Q                               9                                                                                                   .           |                                            D       .




6.1.4 ed                                        P                       vi

1           9               9                           s                                                    {       K               3       \                       "               P                                                           B                        <ESC>               .       \vi"

                G       1               \vi"                b               \ed                  P       "           ^                       G                   c                       t               t                                   \:w"                D    j   n               \:q"
        vi                                          ^   :                                                                                                                            \ed                         P       "                                                ?       ?                   3       :

:   3    \ed                        P       "               b       %        ?



                                3       \               "        \:"P                                                A           r                                                           \ed                         P   "               %                       \ed              P   "               .

3   \:"         X                                           \ed"
                                                            K                                    9               _                                                   \ed"                                    \vi"                G                                   \        _                   "
                                            b       \sed" Stream Editor                                                                                                                      ?                               P           3               a                        +




                                                                                                                                                             96
Chapter 6. Tour of Tools                                                                                                                                                                                                                                                                    6.1. V-eye

         3       .        \ed         P    "
                 :w                                                 D           \write"                                             j       n                           |           3       \:w"                                    j           n           (

                                                                                            j           n




                 :r   j       (                                     \read"                                                              j           n       \                                   w           3       *                                   H               8               y               _

                                                                        \include"
                 :q                                                                         \quit"                                                              \vi"                                |                   \:q!"
                 :1                                                     *                                                           1
                 :12                                                    *                                                           12
                 :$                                                     *                                           t                                                       \G"
                 :/keyword                                                  0    \keyword"                                               9                      C                                       |       6                   \:"                         #           3                           P

                                                                                \/keyword"
                 :4,12s/ABC/DEF/                                                    4                                                   12                                                              \ABC"                               W       \DEF"                           t                       \/"
                                                                        |       6



                 :4,12s/ABC/DEF/g                                                       4                                                12            \ABC"      \DEF" \4,12"          X       b                                   K                       W

                                                                        P          \s"                                                   \search and replace" \ABC"                                                                                                                             0       n    "

                                                                    C           \DEF"                                                               W \g" \globally"
                                                                                                                                                        %                       C                                                                                                       3       !            /

                                                                    A                       n           "           C                                                 \g"       g                       K                       *                   A               ^       b                       J

                                                                    3



                 :1,$s/ABC/DEF/                                                  1                                      t                                                                       J                       j   n                                                                   \ABC"
                                                                        W       \DEF"                                           t                                   \/"                     |   6



                 :1,$s/ABC/DEF/g                                                    1                               t                                                           X       b       \ABC"                                       W       \DEF"
                 :! ls -la                                                                                  $                                           \ls -la"                                            /               \vi"                        .               \vi"                        A   J

                                                                    $           X           |                                   ^                                                                       3       9               $           /                                       |       3       \:"
                                                                                \ "                                 Q                               $                                           9                                   |           3                               \vi"
                                                                        `                           $




9                                           b           :       R                       M                                                               A           \:4,12s/ABC/DEF/"                                                                                                   UNIX                 X

    \regular expression"                            9                       3                   9                                   K                                               3                               &                               +



     ?       -            9               \vi"                          p       .                                               Y




     t                                                      3                       P




             n                    G        1        \/"                                             n           "           C                   0                           `                       *                                   3                       n       "       C

                                      ?             j       n                                                                                       n    "          C           `                                               \n"
             N                    A             ?   G                                       \N"
             ZZ                       \:wq"
             .                                      _                           %




                                                                                                                                        97
6.2. sed                            Regular Expression                                                                                                                                                                        Chapter 6. Tour of Tools

                            3       \vi"            /                                                        C       -       A           \Control-D" \Control-G"                                                                                   \Control-V"         Q

                C       -                       A                                           \^D"                         Q                                     Control        P                                                       "              \V" \D"
    W



                                                    .                   .           3                                                z                       2   ]                                &       :::




6.2 sed                                             Regular Expression
3               \                               G                                                   &            \                       |                   9                >       !                   X                           \regular expression"
&               g       \sed"               9                               P                   1                                            1                                    /           E   |       U               ?                        &       \   T   :       &

                                                        K                       ?           ?       .          \regular expression"                                                                                       P       C       F    h

M               r                       W       m                                                    \regular expression"           ed sed awk grep vi                    |                                                                                                P

`                       &                       T       T           W                               \ " {   W                    ^                                   G




        |                                           &                                           9           j        n
                                                                                                                             3
There are three distinct versions of time: it is built in to
the C shell, and is an executable program available in
/usr/bin/time and /usr/5bin/time when using the Bourne
shell.   In each case, times are displayed on the diagnostic
output stream.

And, this is for special cases:                                                                                                              Test], -Test-, and {this}.


    v                           (               \unix.txt"

6.2.1 Find and Replace

    1       1   \sed"               9                           P                                                                            1                                    C           C   -                           A



% sed 's/time/TIME/' unix.txt


    B               3                   C Shell                                 `                           \:s"                                     4                        9                       \s"             !                          \search"
E   \unix.txt"                      9               j           n                       N                                                        X       |                                1           j           n                           \time" \TIME"
                                                                                                                                                                                                                                                       W




There are three distinct versions of TIME: it is built in to
the C shell, and is an executable program available in
/usr/bin/TIME and /usr/5bin/time when using the Bourne
shell.   In each case, TIMEs are displayed on the diagnostic
output stream.

And, this is for special cases:                                                                                                              Test], -Test-, and {this}.


    s                   \/usr/5bin/time" \time"                                                                                      ^                                            .           ^   b           1                        \    "          N                   0

            C                        \sed"
                                        *                   X           |                                        E       N                                                    \time"                                      \/usr/5bin/time" \time"
    39              SunOS                                       \man time"
    4                       a




                                                                                                                                                                     98
Chapter 6. Tour of Tools                                                                                                                                                            6.2. sed                 Regular Expression

    G           b       \/usr/bin/time"                                  X       |                       \/usr/bin/TIME"                                       A                                E                        X   b   <       g    C

                                            3                                \g"
% sed 's/time/TIME/g' unix.txt


/   7                   3       C Shell                      a           \:s" \:gs"
        9           \sed"           t                                                        &                :           :   ?       b           P        <       g   C        -   ]   P




6.2.2               <       g                            ^



                        \               " Beginning of the Line                                                                           :


% sed 's/^t/T/' unix.txt > unix.txt2


9                               1               E \unix.txt"                 9               j       n            N                           0       \^t"             Q                             W   \T"             .       3       \regular
expression"                                     \^"       \                              "           X    |       9                                    W                       \unix.txt"            9       j       n               |    \t"
        \t"                             W       \T"      X       |   B               9                        |                       \unix.txt2"                          /        T


There are three distinct versions of time: it is built in to
The C shell, and is an executable program available in
/usr/bin/time and /usr/5bin/time when using the Bourne
shell.   In each case, times are displayed on the diagnostic
output stream.

And, this is for special cases:                                                                               Test], -Test-, and {this}.


                                    \the C Shell" \the"                                                       W       \The"                                                    \three distinct" \three"                                       \t"
    ^       b                               .                        3



                    ?                                9                                                                            ?


% sed 's/^shell/SHELL/' unix.txt > unix.txt2



6.2.3               <       g                            $

            1           A                           \        "                               t                End of the Line                                                   \$ "            r        B                   3   \vi"
            \$ "                *                                                                :


% sed 's/in$/IN/' unix.txt > unix.txt2


9                           1                       \unix.txt"           9               j       n                    |       \in"                                             \in"         W       \IN"         X       |       \unix.txt2"
    /           T                                                                                IN
There are three distinct versions of time: it is built in to
the C shell, and is an executable program available IN
/usr/bin/time and /usr/5bin/time when using the Bourne
shell.   In each case, times are displayed on the diagnostic
output stream.

And, this is for special cases:                                                                               Test], -Test-, and {this}.

                                                                                                                                      99
6.2. sed                            Regular Expression                                                                                                                                                              Chapter 6. Tour of Tools

                                \using" \in"                                            ^       b                          .                                   3                       t



        #                           :       :               Regular Expression                                                                     r




6.2.4                   <       g                               C       -




\."                      \                  C       -  "       C Shell              3                                          \ "                                 \           C       -       "               \..."   J                            C       -       X

    W               C                   A           \abc" \#t7" 5                                                  :



% sed 's/e.e/HERE.HERE/g' unix.txt
ThHERE.HERE are three distinct versions of time: it is built in to
the C shell, and is an HERE.HEREcutable program available in
/usr/bin/time and /usr/5bin/time when using the Bourne
shell.   In each case, times are displayed on the diagnostic
output stream.

And, this is for special cases:                                                                                        Test], -Test-, and {this}.


9                                                   0       \e.e"                                              \e"                                                     C   -                               0                   2       ]

W   \HERE.HERE"                                                                                                &                   <           g                   ]       1                   \." \^"                                 \$ "
K      \ "  E                           b                   \ "     3                           `        9                         r                   ^       b                               L       F              F            r                r               X

|   3       9                                               \e.e"
                                                            0                           9                      )       b           \There"                                     \executable"                                W   \HERE.HERE"
    3       \HERE"                                      \."       \."                                                                    \ `                               C      "-



                                                                                                                                   %



%   sed                 's/...ee/33$^333/g' unix.txt
%   sed                 's/^/^/' unix.txt
%   sed                 's/$/$/' unix.txt
%   sed                 's/^$//' unix.txt


            t                                                                       j       n                                  t                                                   %




6.2.5                   9                           C                   <   g                           ...]
#                           +           A                   b       9                   C           f     A                        \   |                   Z                   C                   C" \e                   G                   T A r
                                                                                                                                                                                                                                                T               T

    C       "                                           ]                       3           C Shell                                                    r           \ ...]"                 A      abc]   \a"                               T   \b" \c"  T

                    C                                           \abc"                          0-9]                                                        Z                   C               A-Za-z]          J                               T                   C

            :



% sed 's/ Tt]he/THE/g' unix.txt
THEre are three distinct versions of time: it is built in to
THE C shell, and is an executable program available in
/usr/bin/time and /usr/5bin/time when using THE Bourne
shell.   In each case, times are displayed on THE diagnostic
output stream.

And, this is for special cases:                                                                                        Test], -Test-, and {this}.
    5           h                   t           r                               }           space bar

                                                                                                                                               100
Chapter 6. Tour of Tools                                                                                                                                                                               6.2. sed                    Regular Expression

9                                       0       \the" \The"         T                                                           W       \THE" \g"                                  A           3             /           b   0                                                I

                            :



% sed 's/^ tT]he/THE/g' unix.txt
THEre are three distinct versions of time: it is built in to
THE C shell, and is an executable program available in
/usr/bin/time and /usr/5bin/time when using the Bourne
shell.   In each case, times are displayed on the diagnostic
output stream.

And, this is for special cases:                                                                                                     Test], -Test-, and {this}.


    G                                       8           f                   -       3           0                               P       9                  \^"                             3   N                                          X   |               3

    \the" \The"         T                                                                                       3       9                                  \g"         b       ^   b           @                             .        \       "   3

                                                b                       |                       :



% sed 's/ 0-9]/ 0-9]/g' unix.txt
There are three distinct versions of time: it is built in to
the C shell, and is an executable program available in
/usr/bin/time and /usr/ 0-9]bin/time when using the Bourne
shell.   In each case, times are displayed on the diagnostic
output stream.

And, this is for special cases:                                                                                                     Test], -Test-, and {this}.


9                                           0       N                               Z                   C                                        W       \ 0-9]"           9           C                             !                \ 0-9]"                     3       \
    " \                             "                   H           b




6.2.6                   <           g               T       9               C           -




G           1                   K           <           g                   C           -                   0           ]       P                    3         :   :       A                       9         C           -          \*"   r                                   T

9           C       -                   A                   \A*"                            \                                                                              :::                 A"        X       |               \AA*"                \               T       ?

9   A" \t*"                                         \                   T       |                                   "
                :



% sed 's/e*c/EEE/g' unix.txt
There are three distinEEEt versions of time: it is built in to
the C shell, and is an exEEEutable program available in
/usr/bin/time and /usr/5bin/time when using the Bourne
shell.   In eaEEEh EEEase, times are displayed on the diagnostiEEE
output stream.

And, this is for spEEEial EEEases:                                                                                                           Test], -Test-, and {this}.


        9                                       1               0       \                   T                               ?       9        e                 #   c            EEE        C                                                  "           j   n

    0                           \distinct"                                              e                           #                        c            \executable"   e                                                        #           c               \each"
                    e                           #                       c                \case"                                             e              #      c \diagnostic"                                                              e                       #

    c                \special"                                              e                       #                           c
                :




                                                                                                                                                         101
6.2. sed                                Regular Expression                                                                                                                                                                                                    Chapter 6. Tour of Tools

% sed 's/ec*c/EEE/g' unix.txt
There are three distinct versions of time: it is built in to
the C shell, and is an exEEEutable program available in
/usr/bin/time and /usr/5bin/time when using the Bourne
shell.   In each case, times are displayed on the diagnostic
output stream.

And, this is for spEEEial cases:                                                                                                                        Test], -Test-, and {this}.


9   g               0               \executable" \special"                                                                                      .                           \e
                                                                                                                                                                            b                             )                                   b                   T                           ?   9       c       Q

                c"                                   \ec c"
                                                        J                                                                                       :       W           \e c c" \ "                                                       r               E           G               C       -                   9           K

                                                                5                                                               W       m                                           :                 9




% sed 's/                                   */ /g'


            j       n                       \                       |               "                       }                           W       \                   "               }




                        G               c                                   B       .                   ?                                   r                               3                                                     X       .



% sed 's/e.*e/#####/g' unix.txt
Th#####: it is built in to
th##### in
/usr/bin/tim#####
sh##### diagnostic
output stream.

And, this is for sp#####st-, and {this}.


9                                               A                                                               X       X                                           W                                     &                       :           :       \e.*e"                  t                       q       A                   1

      \*"                   G                               G                       C       -                                       5                       X       |                             W                   \e .                             e" \e"                     Q       ^                                       C

    \e"                 ^   %                                                       b                                               \.*"                                        G         1                           \."     b                           L                           \               C       -   " \"
      \         G               C           -                                           T           |               "       g                       X           |                   \.*"                      W        \                      C       -                               T       |           g        "              C

      \e.*e"                                W                           \                   C                       e                               ^           b       C           -         T       b                                                               C   -   "           Q                   0                   C

        \#####"
            W




        /               :   :                       j       n

There are three distinct versions of time: it is built in to
the C shell, and is an executable program available in
/usr/bin/time and /usr/5bin/time when using the Bourne
shell. In each case, times are displayed on the diagnostic
output stream.
;

And, this is for special cases:                                                                                                                         Test], -Test-, and {this}.




        b                                                                       J               j           n       b  \         e      9                           C                                                 ^       b       C           -       T           b                                               C       -       "
    C                               A                   3                                           b           \There are" \are three"                                                                                                   %                   Q                   t                                               n

                            \   t                                               "                                           0                       <           g                   C         b                   9       `      \There                       t                                       X       |

are" \are three"                                                K       ^                                               .                               K           ^       b           \There are three distinct versions of time"

                                                                                                                                                                                102
Chapter 6. Tour of Tools                                                                                                                                                                        6.2. sed                    Regular Expression

        9           \regular expression"                                                                    !       J                   t




6.2.7               &               M




#           :   t                               M               <   g       ]                           y       :               1           J                                                               A       \A\{1,7\}" \\(.*\)"
A                       B       A                                                                                   1       &           b           .                       D       .



                    :                       \{min,max\}                                         A               \A\{1,7\}"
        G           \AA*"                                               \                       T       |                   A"                  3       9           J       ?   b           P                          \1 7 A"
                                                                                                                                                                                                                        0                         !

            \\{" \\}"                       W                   5                                                                   C                                       P                       A           \1,4" \3,5"                   :




% sed 's/e\{2,3\}/####/g' unix.txt
There are thr#### distinct versions of time: it is built in to
the C shell, and is an executable program available in
/usr/bin/time and /usr/5bin/time when using the Bourne
shell.   In each case, times are displayed on the diagnostic
output stream.

And, this is for special cases:                                                                                     Test], -Test-, and {this}.


9                       1       0   \e\{2,3\}"                                                  \2                      3 e"                        C                                   W       \####"                        0   \three"         b

            \e"             :



% sed 's/ A-Za-z]\{5,9\}/####/g' unix.txt
#### are #### #### #### of time: it is #### in to
the C ####, and is an ####e #### #### in
/usr/bin/time and /usr/5bin/time when #### the                                                                                                                                          ####
####.   In each case, #### are #### on the ####c
#### ####.

And, this is for #### ####:                                                                     Test], -Test-, and {this}.


            9                                               G               1                       \       A-Za-z]          "                                                                      C                             K               X

|   \       A-Za-z]\{5,9\}                          "                               \   C                               3   5 9                                             C       "                                \diagnostic" 10  b           C

            X   |                       *       G       9                                           C                \c"            ^           b



% sed 's/ A-Za-z]\{5\}/####/g' unix.txt
#### are #### ####nct ####ons of time: it is #### in to
the C ####, and is an ######## ####am ####able in
/usr/bin/time and /usr/5bin/time when #### the ####e
####.   In each case, #### are ####ayed on the ########
####t ####m.

And, this is for ####al ####:                                                                               Test], -Test-, and {this}.


9                                                           \5"                 ^           b       P                                       \      5        ?                   "       X       |                   \There" \three"       J

W   \####" \distinct"                                   G     5                 C                                       y                    \nct"              ^       b                               v       .



% sed 's/ A-Za-z]\{5,\}/####/g' unix.txt

                                                                                                                                    103
6.2. sed                             Regular Expression                                                                                                                                                                                      Chapter 6. Tour of Tools

#### are #### #### #### of time: it is #### in to
the C ####, and is an #### #### #### in
/usr/bin/time and /usr/5bin/time when #### the                                                                                                                                                                          ####
####.   In each case, #### are #### on the ####
#### ####.

And, this is for #### ####:                                                                                  Test], -Test-, and {this}.


9                     3              5                           b       \,"                         ^   b                                            C                                    \5       "       |                       X       |                   X       b            \5          C           T    |

    "       C                        K                                                          \distinct"                                             9                                    10                  C                                           )           \5           C       T       |           "
<   g            X   |                           t                   <   g                   10      10                                               C                    K               W \####"
                     \\{min,max\}"                                                       g       )           G       1                &                    <           g               J                            |                                               )            :       :               A

9                g



        t                    b                                       }           1                                                `                   <            g       ]                                                            D           <               g                    C               \( <        g

    \)           !               .       \\(" \\)"                           :       W                   5       v                                    :


% sed 's/\( tT]he\)/\1+++++/g' unix.txt
The+++++re are three distinct versions of time: it is built in to
the+++++ C shell, and is an executable program available in
/usr/bin/time and /usr/5bin/time when using the+++++ Bourne
shell.   In each case, times are displayed on the+++++ diagnostic
output stream.

And, this is for special cases:                                                                                                  Test], -Test-, and {this}.


9                                        3       \\(" \\)"                                                       G                    1                   <        g                                        \ tT]he"                                                0        \the" \The"     T

Q                                `           D       3  1        r               r                   A                       /                3                                                              \+++++"                                p           /                   \\1" 9

                         0                                               q       A           3       \\(" \\)"                                                                 <       g                J    X          0                                                    X       |                               0

    \The" \\1"                                           \The"                                           0\the"                                                                                    \\1"                         \the"                               :




% sed 's/n(.*n) n(.*n)/n2 n1/' unix.txt
to There are three distinct versions of time: it is built in
in the C shell, and is an executable program available
Bourne /usr/bin/time and /usr/5bin/time when using the
diagnostic shell.   In each case, times are displayed on the
stream. output

this. And, this is for special cases:                                                                                                                         Test], -Test-, and


9                                    <       g                           \(.*\)t\(.*\)                                                    b                    E           \\(" \\)"                                    X       |       t      \\1"                                              b       \\2"
                             <           g                   \.*"                                                                     C           -                                            g    T       9       g               .       \\(" \\)"                                        J       *

            \.*t.*"                                      |               }                                               C



        X    |                       \(.*\)t\(.*\)                                                       .                    }               \                        C               5                D       3           1   r            2      r                        /                               ]

            \\2t\1"                                                              !                                        w       3           2           r                        /                                        Y               1   r       G                                                |           }

8             \\2" \\1"                                      b                               "                   X

There are three distinct versions of time: it is built in to
the C shell, and is an executable program available in
/usr/bin/time and /usr/5bin/time when using the Bourne
shell. In each case, times are displayed on the diagnostic

                                                                                                                                                              104
Chapter 6. Tour of Tools                                                                                                                                                                               6.2. sed                     Regular Expression

output stream.

And, this is for special cases:                                                                                              Test], -Test-, and {this}.
                                    0               t                            w           3   1           r       y                                    N                t                            C               w   3       2   r                       E




        9                       f                       M            A                               ^       :   U                                    ~            :                               A            :                               ^       U                       w       a

            .                               z                                    &           ^           z                    :       ^                       ?                    9



        t                               1                                    3           G           1           <       g                                                         C       -       A           \." \*"                          A                   /

                                            A                                        0                           \."     9        C   -                                        \               C           -     "                                  \\" \                           "
    :


% sed 's/\./$/g' unix.txt
There are three distinct versions of time: it is built in to
the C shell, and is an executable program available in
/usr/bin/time and /usr/5bin/time when using the Bourne
shell$   In each case, times are displayed on the diagnostic
output stream$

And, this is for special cases:                                                                                      Test], -Test-, and {this}$


9                           0                               F       \."              Q                               W       \$ "                     \\."                                         b           \."              L           !



                :


% sed 's/\//%/g' unix.txt
There are three distinct versions of time: it is built in to
the C shell, and is an executable program available in
%usr%bin%time and %usr%5bin%time when using the Bourne
shell.   In each case, times are displayed on the diagnostic
output stream.

And, this is for special cases:                                                                                      Test], -Test-, and {this}.


9                   j   n                   \/"                 W    \%"                                     \\/"                \\"                                                   \                   \        L           \/"                                 1           $

            b                       L               C            `                           3           G                    \\"         E                                                            b                        L           P                           A


% sed 's/\T/AAAAAAAAAAAAAAAAAAAA/' unix.txt
AAAAAAAAAAAAAAAAAAAAhere are three distinct versions of time: it is built
in to
the C shell, and is an executable program available in
/usr/bin/time and /usr/5bin/time when using the Bourne
shell.   In each case, times are displayed on the diagnostic
output stream.

And, this is for special cases:                                                                                      AAAAAAAAAAAAAAAAAAAAest], -Test-, and {this}.


3   \T"         G                               E       a



                                G               1                        \       A-Z]            "                                            C                        A                               0                    \                               C           T   -           3

r   )"                      \       -A-Z]               "                        |               \       A-Z-]           "                        1               \ -"             y                       3    \"                                  b


% sed 's/                           ABC]/$$/g' unix.txt

                                                                                                                                      105
6.3.             n   y           sed                                                                                                                                                                                           Chapter 6. Tour of Tools

There are three distinct versions of time: it is built in to
the $$ shell, and is an executable program available in
/usr/bin/time and /usr/5bin/time when using the $$ourne
shell.   In each case, times are displayed on the diagnostic
output stream.

$$nd, this is for special cases: $$Test], -Test-, and {this}.


9            <       g           \"                  T   \A" \B"     T                           T           \C"                             W   \        ABC ]         "                    \"                                0                               C   \ " \]"
                                                                                                                                                                                                                                                                       -        T

                     3                           P          \"                                               r                                        t    &                    <       g             \^"                                                      \-" \ "
3       \^"                              t       h                                       \                           P                           \"                     r



         \regular expression"                                                        9                                       5       -            .       \sed"                                   +                                    1           F       \sed"            T




6.3                      n       y                   sed
G            1                       `sed"               K                                                       \search and replace"                                               _                                  3           :           :                           \sed"        T




         3       G               1                                                                       K               E       j       n                     \   N                "                 A                                    E

                             \sed"
% sed '1,6s/the/THE/g' unix.txt


9                                            \unix.txt"                      9               j           n                                                         6                        \the"          W       \THE"                                   9                        G

1                    3       \s"                 G  \1,6"
         A                               E               b                       C                                                       J



% sed '/shell/s/the/THE/g' unix.txt


    9            \unix.txt"
                         1                   3                                       j               n                                            b       \shell"               9                 C                                                                        \the"
W       \THE" \/s/the/THE/g"                                                                 K                       G                                                                        3           E                b   \shell"                 9           C

                  \s"        X       |       3                       G                                           g               \/shell"                                   3       \vi"                       n   "       C                           \/"
         \sed"                       |                       l   *



% sed '3,5 d' unix.txt
There are three distinct versions of time: it is built in to
the C shell, and is an executable program available in

And, this is for special cases:                                                                                                          Test], -Test-, and {this}.


9                    j       n                           3                   5           l           *                                           \d"                   \delete"                                    K           |                       C       C                        |

                     }               A                           l       *                                                           C                         T                                      r                    |



% sed '3,3 d' unix.txt
                             T

% sed '3 d' unix.txt

                                                                                                                                                               106
Chapter 6. Tour of Tools                                                                                                                                     6.4.         +       grep

        |               b   n       "   C           l   *



% sed '/shell/d' unix.txt
There are three distinct versions of time: it is built in to
/usr/bin/time and /usr/5bin/time when using the Bourne
output stream.

And, this is for special cases:                                                      Test], -Test-, and {this}.


9               b       \shell"             C               *



    t                           \delete"                                    \sed"                         j   n



% sed -n '3,5 p' unix.txt > 3-5.txt
/usr/bin/time and /usr/5bin/time when using the Bourne
shell.   In each case, times are displayed on the diagnostic
output stream.


9           j   n                       3               5           h                   w       \3-5.txt"      9        j       n              \p"           \print                       K

|               C                   ^       b   }                                           0                     \-n"   9                  option            G       c           9

            4           \sed"
% sed -n '/shell/p' unix.txt
the C shell, and is an executable program available in
shell.   In each case, times are displayed on the diagnostic


9       .       b       \shell"             C           h                       E       \d"                         \-n"
    ?               \sed"           3       9                   a           .       9                               ?       {       N                    &            0                   h   :




6.4                 +           grep
#           :                                   \regular expression"                                          \grep"                        t


% grep shell unix.txt
the C shell, and is an executable program available in
shell.   In each case, times are displayed on the diagnostic


        .       b       \shell"                                                 9                   G              \sed"                8                             3               j   n

0           9               j       n       b           n   "       C   `                           \grep"
% grep shell *
tools.tex:shell.   In each case, times are displayed on the+++++ diagnostic
csh.manpage:     Symbolic links can fool the shell. Setting the hardpaths
csh.manpage:     To detect looping, the shell restricts the number of alias
intro.tex: full name shell


    9                           |       :       \grep"      .       X   b           \shell"     C                        K                           v                        3           j   n




                                                                                                    107
6.4.                     +       grep                                                                                                                                                            Chapter 6. Tour of Tools

         3                       \grep"              `                               0            n       "       C                   S   r        R                                 W       ?                   Y           .       9             |

                                         j



% grep * *


                                                         3               G                                    X       b       j   n                              r           L                   0                       b       r       \*"
     r                       L                                                                3           C Shell                       \*"                  \   X   b   j   n   "       X   |       3           \grep"                        G

     $       \                                   \*"                 W       X       b    j       n               (       C           \grep"             Q                   @                               @                            \*"          3

S    r       E       'F          /



% grep '*' *


                                                         S       r               3       C Shell                                      S   r             S    r           -           3   y           G                                         C   -

             A       \ " \$ "                                            (                                                        Q



                 3                           &               \regular expression"
% grep ' tT]he' unix.txt


                     n                           9               0               b       \the" \The"      T



% grep '\.' unix.txt
% grep '.' unix.txt
% grep . unix.txt


             9                                                                            :                           %                                      .       j   n                               *
                                                                                                                                                                                                                     6


6.4.1 grep                                                   4




#                            &                   :       :       \grep"                               4       b                   ?




-i                                   ;



                                     % grep -i 'Shell' unix.txt
                                     the C shell, and is an executable program available in
                                     shell.   In each case, times are displayed on the diagnostic


                                     \-i"            4               \ignore"                                                             \   E                      "               0   \Shell"
                                                 \-i"                  \                                              "
-v                                   ;



                                     % grep -v 'shell' unix.txt
                                     There are three distinct versions of time: it is built in to
                                     /usr/bin/time and /usr/5bin/time when using the Bourne
                                     output stream.

                                     And, this is for special cases:                                                                                    Test], -Test-, and {this}.
     6X          b       G                           \regular expression"                                                         K           |     g   \grep"                                           :           5       -                     \regular
expression"

                                                                                                                                                  108
Chapter 6. Tour of Tools                                                                                                                                                                                         6.5.      +       cut

                    \-v\ \invert"                                                               \       8    D       "               .           \ \             b       n       "   C                   8




-n                  ;



                    % grep -n 'shell' unix.txt
                    2:the C shell, and is an executable program available in
                    4:shell.   In each case, times are displayed on the diagnostic


                    \-n" \line number"                                                                                   3           8                   N                       G                                         r

                                                j       n               /                           r                        \cat -n" \nl"                                               b   v



                    % grep -n ^                                 file


                            3       r                               b   \ "     r                   \cat -n"                                                                 |                           l   *




-l                  ;



                    % grep -l 'shell' *
                    cmd.tex
                    csh.manpage
                    intro.tex
                    login.sample


                    \-l" \list"                                                     \           .                b       n           "       C           j       (                       "           /




-e                  ;



                    % grep -e '-Test' -n unix.txt
                    7:And, this is for special cases:                                                                                                Test], -Test-, and {this}.


                    9                   f                                           X                       0                n           "       C           b       \-"             X   |                               \grep      '-Test'         "
                    `           \illegal                                        option -- T                                  "               G       >           .   \grep" \-"                  .                   W         4         G   0

                    r         \grep"                                        9       \-"\ "                                           4                           \-e"            9               4           9              \grep"
                    .   \-Test"             :       W                                  \-T"                      :       W                   4                               u           g                       4   `    \-e '-Test'"
                        :   W                               Q                                           4            X           |           \-n"                            3       \-e     '-Test'                 "         |




     \grep"                         1                   9                               |                   \man grep"                                       9       .




6.5             +           cut
#        1   \cut"
     . \cut"                                                    B                           4                                                \-c" Character                                              \-d" delimiter                          \-f"
     eld                3       :



% cut -c1-7 unix.txt
There a
the C
/usr/bi

                                                                                                                             109
6.5.            +       cut                                                                                                                                                                           Chapter 6. Tour of Tools

shell.
output

And, th


9           1           \unix.txt"                              9               j       n               \   N                   "                   \1-7" \             C       (character)"              6               \-c"       \   6   C

    "                                                   P                   1-7                                 C



% cut -c-7 unix.txt


9                                                                                                       R           C       -                   H   ^       b           `                       \1"
% cut -c7- unix.txt
are three distinct versions of time: it is built in to
  shell, and is an executable program available in
in/time and /usr/5bin/time when using the Bourne
   In each case, times are displayed on the diagnostic
 stream.

his is for special cases:                                                                           Test], -Test-, and {this}.


9                   ^   b                           F       C       -               H           X       |                               \                           t                   C   -   "
% cut -c7 unix.txt


                    \7"                                                                 7       C       -



        T                   8                                                           H           C       -



% cut -c1,3-7 unix.txt
Tere a
te C
/sr/bi
sell.
otput

Ad, th


9           6                       C       -                                                       b       `                   j       n                                           !            K    E               ?          |

                                    \cut -c"                            ]       P       8                                                               A



john:ACrBqjTb8JmxQ:149:200:John Cooley:/home/users/john:/bin/csh
cpy:,xcrggtKWJTUA:172:200:C. P. Y:/home/users/cpy:/bin/tcsh
math:po.isgMVOPEw:110:200:Guess Who?:/home/users/math:/bin/sh
smith:ouzoi1EiDuJuk:129:200:Bob Smith:/home/users/smith:/bin/csh
student1:ou..41EiDuJuk:159:300:Talking Head:/home/users/student1:/bin/csh


9                           l               \/etc/passwd"                                           j       n                   '                       3       8           X   b                         \full name"                    s

    \cut -c"                    ]       P       q                                           .                           X           3       N                   H   K                                         K   3   N              5
       eld                          |       \:"                             9                                                           |



% cut -f5 -d':' /etc/passwd

                                                                                                                                                    110
Chapter 6. Tour of Tools                                                                                                                    6.6.         5       -             paste

John Cooley
C. P. Y
Guess Who?
Bob Smith
Talking Head


\-f" \-d"                               g               9                               1   6       \ 5                " -f5                 L                       \:"   5

  -d':'
        Q                           |           g   8       9



% cut -f1,5 -d':' /etc/passwd
john:John Cooley
cpy:C. P. Y
math:Guess Who?
smith:Bob Smith
student1:Talking Head




6.6             5       -                       paste
#           5       -                   \paste"
     \paste"                                                            j   n       \           "    3       R                  :           '    b                     j   n     &

    \p1" \p2"
% cat p1
Line 1
Line 2
Line 3
Line 4
% cat p2
L1
L2
L3
L4
L5
L6


    3                       \paste"         R



% paste                 p1 p2
Line 1                  L1
Line 2                  L2
Line 3                  L3
Line 4                  L4
                        L5
                        L6


    R               j       n                               j       n           N                        K       <TAB> "    5       X   |            @       j                 \Line
1<TAB>L1"                       A                               5               r           |       \-d"                   \cut"
                                                                                                    111
6.7.             b       tr                                                                                                                                                                   Chapter 6. Tour of Tools

% paste -d':' p1 p2
Line 1:L1
Line 2:L2
Line 3:L3
Line 4:L4
:L5
:L6
:


        1       \paste"                  E       \           "j   n                                   H           @             .                            @                |           E                   j   n       \paste"
                     9       `                                \-s"                    4



% paste -s p1
Line 1 Line 2                                     Line 3                  Line 4


\-s" \serial"                                                         1                           j       n       N                                  #   R                        W                       8       y       j   n         \
    C" <TAB>-            W                               Q                            |               W                    5         C           -                   G        1           \-d"                4



% paste -s -d':' p1
Line 1:Line 2:Line 3:Line 4:




6.7                      b               tr
                &                    .   \tr"
        \tr" \translate"                                                      )   (               L                              C       -                                W                       C       -           :


% tr T @ < unix.txt
@here are three distinct versions of time: it is built in to
the C shell, and is an executable program available in
/usr/bin/time and /usr/5bin/time when using the Bourne
shell.   In each case, times are displayed on the diagnostic
output stream.

And, this is for special cases:                                                                           @est], -@est-, and {this}.


9                                1           .   \unix.txt"               9               j       n                   \T"   K            W           \@"                      \tr"                                                default
input                                              standard input                                             A                                                      j   n                        \<" \               0   "
     \tr"                                            |                                C       -               C                              |                                                C       -               A             C       -

    Newline                                          C   -        Tab                                         3        9                             C   -       `                    |       \\ascii_number"                       ]       P




% tr '-' '\12' < unix.txt
There are three distinct versions of time: it is built in to
the C shell, and is an executable program available in
/usr/bin/time and /usr/5bin/time when using the Bourne
shell.   In each case, times are displayed on the diagnostic
output stream.

And, this is for special cases:                                                                           Test],

                                                                                                                           112
Chapter 6. Tour of Tools                                                                                                                                                                                             6.7.        b            tr

Test
, and {this}.


            j       n                       \-"                 B                   W                                     \\12" \Newline" ASCII                                        D                   |       \man ascii"
     ASCII                              0                                                   C       -                   ASCII  D




    Beep        #                                       007
    Backspace                                           010
    TAB                                                 011
    Newline                                             012
    Escape                                              033

         \tr"                   |                           P                   C           -                       A


% tr ' a-z]' ' A-Z]' < unix.txt
THERE ARE THREE DISTINCT VERSIONS OF TIME: IT IS BUILT IN TO
THE C SHELL, AND IS AN EXECUTABLE PROGRAM AVAILABLE IN
/USR/BIN/TIME AND /USR/5BIN/TIME WHEN USING THE BOURNE
SHELL.   IN EACH CASE, TIMES ARE DISPLAYED ON THE DIAGNOSTIC
OUTPUT STREAM.

AND, THIS IS FOR SPECIAL CASES:                                                                                          TEST], -TEST-, AND {THIS}.


9                   .                       C   K                   W                       C                                           P                 l       P        9                     \a-z" 26      b             C    -

     \A-Z"              b           26                      X           |           |                   E                                   |         :       .       \ A-Z]"              W   \ 0-9]"                               \tr"
0                   E       T               C   -       `                                       %



         \tr"   b                                                       4   &   .                                                  \-s"               \squeeze"                                    )   (        L                     \   ^

D    "                          \   ^       D   "   %                                                   .       9                  C    -       3   \translate"                                W


% head -1 unix.txt | tr -s 'e' 'E'
ThErE arE thrE distinct vErsions of timE: it is built in to


9                           G                                       \unix.txt"                                                              X       \tr"                                        \e"            W            \E"           3

                                                9                   \E"             W                   b                  X   |                    \three"                    W           \thrE"
% tr -s ' ' ' ' < unix.txt
There are three distinct versions of time: it is built in to
the C shell, and is an executable program available in
/usr/bin/time and /usr/5bin/time when using the Bourne
shell. In each case, times are displayed on the diagnostic
output stream.

And, this is for special cases:                                                                                          Test], -Test-, and {this}.


9                   J               .       9                                           W                   b



                                .                   4                   \-d" \delete"                                                                             C    -           *




                                                                                                                                       113
6.7.         b           tr                                                               Chapter 6. Tour of Tools

% tr -d ' ' < unix.txt
Therearethreedistinctversionsoftime:itisbuiltinto
theCshell,andisanexecutableprogramavailablein
/usr/bin/timeand/usr/5bin/timewhenusingtheBourne
shell.Ineachcase,timesaredisplayedonthediagnostic
outputstream.

And,thisisforspecialcases: Test],-Test-,and{this}.


  |    :                          K                *     9



% sed 's/ //g' unix.txt


             3       T                s           \tr"           \sed"   b         E           |   ~   f   :   :

  b                               E       ]   P
                                                                 7




                                                                                              He said Mama, Mama
                                                                                             The President's a fool.
                                                                                       Why do I have to keep reading
                                                                                          These technical manuals ?
                                                                                            from Amused To Death
                                                                                                    by Roger Waters




  7   \tr"       E            C   -       b                  C       : ::




                                                                             114
Chapter 7

.                                   C Shell Script

UNIX                        ?                       3                               }                                P                                 ?                         \ " $           X   6                                           3                   a           B

    l       +                                C Shell                        8       ?                        *                   3           9         a         &                           M                   :       :           \ "
                                                                                                                                                                                                                                     $           A                   9           *

    J       )       R                   )                               }                        P                                       ?       b   \   .       "                   3       DOS                             \   1   g       j       "           3       UNIX
            &                       \Shell Script"
                .       .           C Shell Script 1


7.1                                                                     Shell Script
                    :



 1          #!/bin/csh
 2          set a = 1
 3          set b = 2
 4          echo a = $a
 5          echo b = $b
 6          if ( $a == $b ) then
 7              echo a == b
 8          else
 9              echo a \!= b
10          endif


        9                  shell script           \#!/bin/csh"                                                                                                           3       G                   B           1                                                               9

    j       n        \C Shell"
                            /                  \/bin/csh"                       +                                                                                            |               N                                                                                   5

    '                  a b               \1" \2"                                         &                                                                               "               J           .                                                               \echo"
              C       \printf"  +                                                            K               .                                                                                                               G               \$ "        r

                                    X  6    D10     w                                                                                                        f               \       P               \   a
                                                                                                                                                                                                         A                                           y           b
J            \a == b"                       9 \a != b"      G  9    >                J                                                                                                               \ "             G                               E       a    \n"
.           \ " C Shell     3        \history"                                                                                       X           |           E       a       /                                                                                   |   .   9


     13                     1       G                       '                                P           b       t                               P     F     C       +       PASCAL                          T       BASIC                       K           |       4   Q   b
1    C Shell                                ?                   P       +                        z   b                   j   n                                               C           +               8       F       Q               .           unix                "   >
W       unix                        ?           T       T   W




                                                                                                                                                 115
7.1.                                                            Shell Script                                                                                                                                                  Chapter 7.                      .                   C Shell Script

            P               W                               j       n                   '           (               \equal"                             Q                               B                                             P                   \                   "       #

            \./equal"
                                                    .                                       \#!/bin/csh"                                        `                                                                        \C Shell"                    +                           X   |

                            \C "        $                                                   |                                           .                           \C "            $                X       |                \ /.cshrc"                                                      \ " :

                    g                                                           9               P                               `                                       @                       3                G         \ "    $                                                           \ "         $

                    \           /.cshrc                             "       Q                                                           |                                                                    K                                                R       9                   `                               \
    $       "           /                                           \ " $                           /                                       \ " $               `                                ^       s                    \               $       "           .                           \           $       "
B                                   t                   3


a = 1
b = 2
a != b


        9                       P                                                                       .                                                                   K                   \#!/bin/csh"                                          X                           L   |       C               X

                                                                $                   \set"                   '                                                                       P       +                                     \echo"                                              3                       `       ^

                            :               G           >               \$ "                                                                        C       T           C                                \if : : : then : : : else : : : endif"                                                                   \if"
    \endif"                             W       E           n                           b       \then"                                      \if"        !                                                            0    s



        b       `                                   P                                               A           X       w           9       `                               \   8               " debug                                                   |                           \echo"                          3

    P               &                       a           w                       \echo"                      9                               |                           N                                                             |                                                       b       ?       ?

]                                   3                                   \#!/bin/csh"                                                                        \-v"                                4                                                 N       M                                           K




#!/bin/csh -v
set a = 1
set b = 2
echo a = $a
echo b = $b
if ( $a == $b ) then
        echo a == b
else
        echo a \!= b
endif


            \-v"
set a = 1
set b = 2
echo a = $a
a = 1
echo b = $b
b = 2
if ( $a == $b ) then

echo a != b
a != b
endif


                                                                9                   P                                       N                               |           C       X                                                     9               9                                       \-v"                    4

    o                                                   G               1                   3                       \       $   "                        \ /.cshrc"                                                                                                       /                   b       `

    z       9               H       X                           D                   P       /                                           3       \ /.cshrc"                                                                    '                                   D               r   X                               >

            9       `                                   |                   \-f"                        4                                            \ /.cshrc"     :                                                                     #               /                           3               |

:   9                               \-f"                        4                           &           A




                                                                                                                                                                116
Chapter 7.                   .               C Shell Script                                                                                                                                            7.1.                                   Shell Script

        B                    b                                               \yes"                                                |                                                                    script

 1              #!/bin/csh -f
 2              if ( $#argv == 0 ) then # repeat printing 'y'
 3                  while ( 1 )
 4                         echo y
 5                  end
 6              else    # repeat printing all arguments
 7                  while ( 1 )
 8                         echo $argv *]
 9                  end
10              endif



                +                       \$#argv" \$argv *]"                                      |   C                                                    G                           \number of arguments"     \
                     "                  \       "      \ls .cshrc
                                                             X           b                                   f       A                                                    .login 9       "          \       " \2"
                                 \.cshrc"         \.login"                                                                                        X       b                           \
                                                                                                                                                                              .cshrc .login           "
                3                                                9                       b                       script                                                                    A                                                                 /

:                        #                                                                                                f                   \                             2 6 10                                     x           \if : : : then : : : else
:::     endif"           3           \if"    9                       \                           &                   :    :       \                                             "                  A                                      1       3

    ^       b                                                                                        3 4 5                                    3           :               3 4 5                                %                     \while"
            f            \               3       \                   "       /                               f                A                   \true"                                                       |                                       \             "
/           f                                        c                               J                                   \end"                                                \while" \end"                                W   E                      \if"       g

            \endif"                                      :       3               \                   "   /               \1"                          \               G         "          X   |                                   \echo y"       9

J           :  2-5                                                                \      A           ^       b                                                                    2   `y' "
        !                            6 7 8 9                                                                                  \       J               b                                                                                       .

    "
                                     P                   \#"             C           r                                                                                                 Q                                       \#!"
            &                    v       .       9                                   P       D       W           \my-yes"                 9                       j           B            .           P                       \executable"
A           chmod +x my-yes


% ./my-yes
y
y
y
^C
% ./my-yes I Love UNIX
I Love UNIX
I Love UNIX
I Love UNIX
^C



B                   \Control-C"                                                  *                               Q        3                   \while ( 1 )"                                        |       .       ^                  *       9

                    \yes"                                T                                                   \             "          T           |\while"    C



        9                                                }                                                   b                \                                   "       |




                                                                                                                                              117
7.1.                                        Shell Script                                                                                                                           Chapter 7.                       .            C Shell Script

                 $#argv                                                                                                           number of arguments
                $argv *]                                                                                                              all arguments
                  $argv                                                                                                               !   all arguments
                   $*                                                                                                                 !   all arguments
                $argv 1]                                                                                                                        argument 1
                $argv 2]                                                                                                                        argument 2
                $argv n]                                                                                                           n            argument n
               $argv 1-3]                                                                                                           argument 1, argument 2, argument 3
                $1 $2 $3                                                                                              !

               $argv 1-n]                                                                     n                                   argument 1, argument 2, .... argument n
            $1 $2 $3 .... $n                                                                                          !                          n
                   $0                                                                                                     P                                   \$argv 0]"
             $argv $#argv]                                                                                                                         t




                +



    1   #!/bin/csh -f
    2   set number = ( 1 2 3 4 5 6 7 8 9 10 )
    3   set cnt = 0
    4   foreach n ( $number )
    5       set cnt = `expr $cnt + $n`
    6   end
    7   echo "1+2+3+4+5+6+7+8+9+10=$cnt"


9                   P               L   \number"                                                                                               /       )                           W                      1 10  C                            Q

                            \cnt"               \0"           '                               #               3           4 5 6                                                |           \foreach : : : end"                       W   E       R

                            P   \foreach"             )   (               L                   j       E       N               /           )    W                                            \foreach"                                    #

                                           \n"
                                             (    C                           9           (       C        \foreach : : : end"
                                                                                                                  3                                                                    /    b                                            X   b

            W                 \$number"                                                               \set cnt = `expr $cnt + $n`"                                                                          9                P                       3

                    P       +        \cnt = cnt + n"                                              3     C Shell                \expr"                      |

    \expr                   $cnt + $n"         \ "    3                       I                            \ "                                                             w                        `                   K        .               3

        `                               t                                                                         \$cnt"
                                                                                                                  S       r                                                                                 A                    t

    S       r                                                         |               :



        X       |       J               P                 @                                                               1                   10                   C           R                                                     A   h




1+2+3+4+5+6+7+8+9+10=55


        9                       P       @     |                   F



#!/bin/csh -f
set cnt = 0
foreach n ( 1 2 3 4 5 6 7 8 9 10 )
       set cnt = `expr $cnt + $n`
end
echo "1+2+3+4+5+6+7+8+9+10=$cnt"


                    &               \set         number = ( .... )                                    "   9                       J       *                    #       .                        W       p                   \foreach"                r

/



                :                                                         .       1               10                              C                R




                                                                                                                              118
Chapter 7.                    .           C Shell Script                                                                                                                                                   7.2.                   Shell Script                     j    (




#!/bin/csh -f
@ n = 1 # set n = 1
@ cnt = 0           # !    set cnt = 0
while ( $n < 11 )
@ cnt += $n # !    @ cnt = $cnt + $n                                                                                                               set cnt = `expr $cnt + $n`
@ n += 1    # !    @ n = $n + 1
end
echo "1+2+3+4+5+6+7+8+9+10=$cnt"


9                                         \while"                                         f                   \                                   n       ^            W           11      `

          n                                  cnt                                                                      .                       n               L




                              9                                   '               ]                               \set"               ]                                                    ]   P                                      \expr"                       .

3       C Shell                           B                                           \@"                                                     b    \#"                                 2       K                                                                   b

                      |                           !                                                       \expr"                                  \expr"                       \set"                              \set"                        f       :   :

>             -




7.2                       Shell Script                                                    j           (




    :         \foreach"
#!/bin/csh -f
foreach file ( *.ab)
        set base=`basename $file .ab`
        mv $file $base.cd
end


UNIX                                      ^           b                           DOS                                 \rename"                                                     |       .                          j           n            g           (

A   \ren          *.ab *.cd                       "       A                           |                   \mv         *.ab *.cd                       "            |                                                      0       5        .                           \*"
                      L



                  1                       UNIX                        b       Q       ^       b       DOS             ?                   ?           &   Y       -    3       9                   F                                   UNIX                @

DOS                                       F               P                                           script                      |                               9                    P                              \foreach"                    .               (    C

 \.ab"                                j       n               W       |       \.cd"                                               \ren             *.ab *.cd                       "                                    \basename"                         9
    3                                                 j       n           (       C               G               (       C




                                                                                                                              P       D       R                            P      \                           "               Q                                H   j

              @                   9                       P                                               W   j       n                                   #                    C Shell                            |



%   foreach file ( *.ab)
?   set base=`basename $file .ab`
?   mv $file $base.cd
?   end
%


              3                     \foreach"                                                                 C Shell                                                                                                                  X       |   #

                          b       \?"                                                                                                                             \end" C Shell                                   Q                            B


    2                 t
    3         \man basename"                                  :                                                           b                        dirname                     |       5   -   .       .




                                                                                                                                      119
7.2.                    Shell Script                                         j    (                                                                                                                                    Chapter 7.                       .            C Shell Script

                                                                 D           9         ]           P                           |                               W       j           n                                                F                            P                           9

        script                           /                           !                     `                               ?                                       g



        :       t




             1          #!/bin/csh -f
             2          @ cnt = 1
             3          echo I will count from 1 to 100
             4          echo and pause at every ten numbers for confirmation to continue
             5          echo -n Press any key to start :
             6          set key = $<
             7          while ( $cnt < 101 )
             8                  echo This is $cnt
             9                  if ( `expr $cnt % 10` == 0 ) then
            10                     echo -n "Continue or not (Y/N):"
            11                     set key = $<
            12                     if ( $key == 'n' ) exit
            13                  endif
            14                  @ cnt += 1
            15          end
            16          echo DONE.




9                   P    x               >                                            "        8           \                                       ]                           \$<"                5                   \echo                -n   "                  C Shell              3

                         C       |                                                             *                   1               3       !                                   #                   6                   '                                        \key"
      \$<"                                                               "   8                 @                   F           1           T               1                                               standard input                                   \                            #

    \while"                          T                   z



                    9                            \           \                   cnt                                                   10                  J           t               "   A                       J           \                                     "       A

                                             \                                         \n"                                         \exit"                                          $                   @                   J

100                 c



                                     9                       script                                                        \                           :                                       b               ^                            :                                    B   K   z

                    N            M
                                                 4

                             &                               9                        \                        "                       C Shell Script                                              "  \source" \ "
                                                                                                                                                                                                           a                                                                                     C
Shell Script                                                     |                                 @                                                                               !          \source"                                      `

    $                                                                    1        3    !                           $           /                                                     script                    script               `           q       A

                         X       |       A                                            \#!/bin/csh"                                             `                                   \       /bin/csh"                                    8           y                                $

                        script                                                                     Q                   A                                                           \#!/bin/csh"          script C Shell        9                                                             ^

n                        P       X                                   $



        C Shell script                                                                     y           2       +                       h                                                                           N               shell script                          ^       ?   N

                                             A                               UNIX                                          |       C   n           "   C                       \foreach"                                            ^       %               w                        A

            ?                    M       .                       ?       9       C Shell Programming                                                                       *               ]                   3   t                a                                    h                   P




    4                        \-v"                    4




                                                                                                                                                                   120
Chapter 7.   .   C Shell Script                       7.2.    Shell Script   j   (




                                                            For millions of years,
                                                  mankind lived just like animals.
                                        Then something happened which unleashed
                                                    the power of our imagination.
                                                                We learn to talk.
                                                          from The Division Bell
                                                                     (Pink Floyd)
                                                             by Stephen Hawking




                                  121
7.2.   Shell Script   j   (         Chapter 7.   .   C Shell Script




                              122
Chapter 8

X Window System

                          X     UNIX                                                  ^       b                   E               n                                               3                UNIX                                    K                   n        X                       3   9

`             =           MS-DOS    MS-WIN                    K       b                                                               |                               n                                                                        UNIX                         a       y

        +                     )       Q               y                                               @                                                                                   C       *                                                            Z

                                                      U                                           :-) X                                               W                   O                        \           L                                                            T

x                     .               3       y                   @                                           |                                                       \                                O                   6                   ^       +                D                   X
                      |       z                       3                   K                   :                           \                                                               v                                        y       "       8                        I       5

                              X                       D           |                                   -                                           &       P           &                   ^                                                UNIX
                      {       K               |                       X                                   =           PC                                                                       9                                   Micro$oft Windows
             X                                            L



        X Window                                              J               ^                   G                                                   2                                                                                P                       C Shell
                      X       |                       b                           j       n                   !       P       J               X                                               C Shell \.cshrc"         b                                   !    P                           9       j   n

         |                    '                                                               J                       X                                                       Q                                        |               ?               9            j   n               '                   \
$   "                                             b                                                       A                                   y       9                                                                            |                                                3       9

              &                                       T                                                       ?               m                                   '



                  j       n               @                   j                                               X                                   t                                       \.xinitrc" \.Xdefaults"                                                                               b

j   n   3                                                         `                           5       -                                                       1                           R         Sun Sparc  |                                                                                +       J

        X                         @                       '                                   y               X Window                                                                9                                                    1                    T           P                           9

                                                                                          3       \                               UNIX                                            P                            X WINDOW                                                         P       !
                          :::




8.1 Open the Window

        @             1       R



        login                                 &                                                   UNIX   Shell                                            X       3           9               $            t                                           \console"                            3   9

                              ]       -               .                                   b                Sun     X              K                           3       2                                            G                               s       "

             SunView                                                                  W           OpenWindows OpenWindows                                                                                                      X                                            4       Q

    b                 -                                                                   &                      X    .                   W                                                                            b                       (




                                                                                                                                                                  123
8.1. Open the Window                                                                                                                                                                                                                                                Chapter 8. X Window System

        \openwin"                                                                                       @              Bourne Shell \     " (Shell Script)          9                                                                                                                           P

\/usr/openwin/bin/openwin"                                                                                            home directory    \.xinitrc" .\Xdefaults"     :                                                                                           b       ^           b

9                   j               b                                       ^           b                  \/usr/openwin/lib"
                                                                                                            Q                                                                                                                                                                                           j                                           A

                Window                                  ]               P                           \openwin"                         1                                             @                                   =       b           9                       j



        ?                       3                   '                                   openwin                                                         X Window                                                                        q           A                                       (                           PATH                5

    0                               \openwin"                                                                       j                                                   \/usr/openwin/bin"  3                                                                                                           0                   0

            9               j       n                                       j                                                               |                   more cat                                    :                           /                                   v                           B       D                   F       ^       b

    j                                       9                       1                   UNIX                                                                                ( le permission)
                                                                                                                                                                                    j           n       l       V                                                                                       UNIX                    W

1                           j                                                                       j                                       |       .                          \ "                                  j       n                           W                               j                                chmod          9

            |
                            2                                           \ " 1                                   j           n                               j                                               j       n       (                                                       `                   UNIX                            6

                                        UNIX3                                                       F                                       A                               j                                   binary code               UNIX     \
    "                               UNIX 9                                                              j                                       +                   T                                                     \/usr/openwin/bin/openwin"
                                                                                                                                                                                                                                        1




#!/bin/sh


9                                   UNIX                                    \       |                               Z           C                      /bin/sh                                                  9                               P                           \                                                   Bourne Shell
Script"                                                     1                   9                   Z           C                               Shell Language                                                          X       |           E           y       !                       Shell                   +                       1           9

Z   C                               F       h                               E                   U       9                       +                                                                               b       :       ^           b           U                                                           :                           X           \
            j       "                   |                               9                   Z       C



#!/bin/csh
                T

#!/usr/local/bin/perl
                T

#!/bin/awk
   ........


                            1        CSH PERL AWK       +                               !           i                                                                                                                   K                                                           \           +                                   h       F

    1         \/usr/openwin/bin/openwin"         Bourne Shell Script                                                                                                                                                                                                                                Q               '

(                           Q\ "        \.xinitrc" \.Xdefaults"
                                                        :                   :                                           b           ^       b                                                                                                                   ^   b

t                               \xinit" binary        3              \xinit"                                                                                                                            j                                                   1                                                             X Window                      x

            \openwin"         \ "                       9  \openwin"            C                                                                   X       |                       1                                   k                                                                           |                   X Window                        3

            :               :



                 \.xinitrc" \.Xdefaults"
                        B       b                                                                                                                                       E               E                   ?                                         \xinit"
                                                                                                                                                                                                                                                            B                                                                                           :

           \.xinitrc"         C Shell                                   j                                                                                           R                       `                                               csh <=>.cshrc xinit <=> .xinitrc                                                                            q

A   \.xinitrc"             X Window             X                                                                                                               (                                   :                       b       ^          \.Xdefaults"
                                                                                                                                                                                                                                                b                                                           j           b



xrdb                    /.Xdefaults


    J



xrdb /usr/openwin/lib/Xdefaults


9                                 \source /.cshrc"                                                                                                                  v                                   B               G                                                   C Shell                             `                           q       A

    \.cshrc"                       C Shell  '                                                                       (                                   ]                                           \source .cshrc"                                                                 3                               X Window
            q       A        \.xinitrc"     X Window                                                '                                                                           (                                                                                                                                    \xrdb"                         2

8           y           source            \                     K                                           \                       @               j                   '                       '                                   (                           "               X       |                   |             \.Xdefaults"
    19                                                           Window                                                         ]       P               |                       openwin                             }                       1
    2                           a       b       n           chmod                               1
    3   xinit           3                                         which                                         0                   0




                                                                                                                                                                                        124
Chapter 8. X Window System                                                                                                                                                                                                                                                                                      8.2. X Resources

        X Window
            3                                                                `       :                                                                           Window                                                                             A                                   B       3       X Window
     \.Xdefaults"                                                            f           A           1       .           Window                                                                            9                                                                                            s                                               .           X
Window               q               ^           :                                                                       :                                                               \xrdb /.Xdefaults"                                                             9



        xinit        q   A           \.Xdefaults"                                                '               ?               X Window                                                          (                                                                            X Window                                                        3

G                &                         Window                                                                            b                   P                                             |       3                   K                                9                       Window
                                                                                                                                                                                                                                                                                    9                                                           5

!                        J                                   K                                                       w                       9                       Window                                                                                                                                                     B   W                   $       X

|                        b \       \     xinit                                               D           3                               q           A           \.Xdefaults"       X Window                   '                    ?                                                                           (                           #            \
                         " (Window Manager)                                                                                      |                                         Window                                                               w           B                                           X           |               3           \.xinitrc"
                            \xrdb"     \                                                                                                                         "             binary                                                                                       j                       v       b           ?       9                               X

X   1




        A                :           :                               \ /.xinitrc"                   \olwm &"       \olwm -3 &"                                           T                     :                   b                                                            T

    \olwm" \                                                                 "(Window Manager)              \Open Look Window Man-                                                                                                      (

ager"                                                    C                   =    \olwm" R     Sun                                                                                                                         s        "                       `                                                                                           .

b \drag and drop"                                                                          \drag and drop"                           K                                   X                                                                                                                                              u               l       *               j

n                            .                                                                           j           F                                       .                       Z                                                          H           w                                               |                                           j   n

  \remove"                       *                                               Macintosh                                                                               9                                     @      /usr/openwin/lib/openwin-
sys             @                            X           |                               \.xinitrc"
                                                                                         :                   3                                               j                                 b           /usr/openwin/lib/openwin-sys                                                                                                         9               3

          olwm                                               G



                               X Window                                                                                                                                                            9       `                                                        :           :               b       ^           b                                   Q       Y

    Y       w        T  program \.openwin-init"                          #                                                                                                                                     9                    j                                            9                          H                       A                       b   9

    j                                    Window                                                  P                       3                                                                                                      `                                                               f       A                   Y                   `           3

                 w           *         (texteditor)
                                         O           3                  \.openwin-                                                       _                                                                             3                                                                                                    3

init"             run program                         \.openwin-init"                                                                                                        |                     A                            ^           b                                                                       9               j

    run /usr/openwin/lib/openwin-init               tool cmdtool, le manager, on-                                                                                    Q                   .

line help viewer                                               helpViewer
                                                                 w           3                   K                                                                   A                                         W                                            |                                                                                           .       .

OpenWindows                           \.openwin-menu"             main menu      E                                                           b                                                                                                                  '

        mouse        openwin              menu           "           3                                                               Z                                                                                      b                               }           P                   b                                |                          @   ~   @

~




8.2 X Resources
    h                                                                            B                       @           3       G                               E               .Xdefaults                            9                    j                                           9                       3                   9   :

                X Window                                             K                                                                                                           #                         b           ^        b                                                                                                       f

    C                                C       l                                                                                   H                                                                         #                    X                                   A                    default                                                    C       H

                                                         F                       9                               \X resource"
                                                                                                                         K                   b           n           X                                                                              N                               X Window program                                                            K

T   9       T    K       b                                   E       T                       X resource                 program                                                                                                                                         3                                                       D

                 |   b                                                   P               k           C      X program                                                                                                                                   A       1                                                           OpenWindows
    C                                                                |           3              \.Xdefaults"                                                     j



Window.Scale:                                                large


                 |   .           C                                                               F (default      medium 12 pixels large     14 pixels)                                                                                                                                                                                                          9

    \Window.Scale"                                                                               \Resource Name"       X             X Resource                                          N                                      P           X       !                                                                               K

                             P                                   T                   K                         X Resource        user        P                                                                             z                                                                    |       b           X               A                       .

N      X program                                                                                                         @ X Resource
                                                                                                                                 3                                                   b                                                                                                                                                                      X

    \.Xdefaults"                             j                                       I                                                          (copy)                                             K                   3        H                       P       `           q           A           P           1

    .                                        H           T




                                                                                                                                                                                         125
8.2. X Resources                                       Chapter 8. X Window System

! X-Windows defaults file.
! olwm.ColorFocusLocked: True
! For Gremlin to work in any Window Manager
!sx.focus: on
Xarchie*xarchieFont:    9x15
Xarchie*xarchieBoldFont:        9x15bold
!-------------------------------------------------------
! Original Cxterm Input method with NewFace Modification
cxterm*pointerShape: left_ptr
cxterm*VT100.Translations: \
#override       <KeyPress> F1: string("^ OP")           \n\
                <KeyPress> F2: string("^ OQ")           \n\
<KeyPress> F3: switch-HZ-mode(UserCZ-b5) \n\
                <KeyPress> F4: switch-HZ-mode(ASCII) \n\
                <KeyPress> F5: switch-HZ-mode(PY-b5)    \n\
                <KeyPress> F7: switch-HZ-mode(ZOZY)     \n\
          Shift <KeyPress> F8: switch-HZ-mode(QJ-b5)    \n\
                <KeyPress> F9: switch-HZ-mode(CangJie)    \n\
                <KeyPress> F10: switch-HZ-mode(Punct-b5)    \n\
!~Meta <KeyPress> Escape: insert() switch-HZ-mode(ASCII)\n
!-------------------------------------------------------
Ghostscript*geometry: 500x500-0+0
Ghostscript*xResolution: 60
Ghostscript*yResolution: 60
! xterm window defaults.
xterm*background: darkslategrey
xterm*foreground: white
xterm*cursorColor: white
xterm*pointerColor: red
xterm*border: SkyBlue
xterm*sunFunctionKeys: True
xterm*jumpScroll: True
xterm*scrollKey: True
xterm*curses: True
xterm*loginShell: False
xterm*font:     -adobe-courier-medium-r-normal--18-180-75-75-m-110-iso8859-1
xterm*scrollBar: True
xterm*saveLines: 600
xterm*iconImage: ~/BITMAP/roc.bitmap
Scrollbar.JumpCursor: True
OpenWindows.MultiClickTimeout: 4
OpenWindows.Beep: always
OpenWindows.SetInput: followmouse
OpenWindows.ScrollbarPlacement: left
OpenWindows.PopupJumpCursor: True
OpenWindows.WorkspaceColor: #40a0c0
OpenWindows.IconLocation: top
OpenWindows.SelectDisplaysMenu: True
OpenWindows.WindowColor: #cccccc
OpenWindows.DragRightDistance: 100
Text.AutoIndent: True
Text.MaxDocumentSize: 40000
Text.LineBreak: Wrap_word
!Text.Checkpointfrequency: 700

                                      126
Chapter 8. X Window System                                                                                                                                                                                                                                  8.3. A Little More

Keyboard.DeleteWord: 17
window.Scale: large




8.3 A Little More
                ?           b       1                               Window                       \openwin"  @                                                                   9                                       E                                                   \xinit"                 |

                        G                   1                       \xinit"                   \openwin"     x                                                   9                                                   Q                   9       '

    Q               |           `                               ?                       6             \xinit"                                                                                                                                                           Q           xinit           :

            \.xinitrc"                                          A               ^   \.xinitrc"
                                                                                            b            Surprise               9               j                                                                           b           Q                                                           b

    F               M                       H                   w                                xterm                                                                                      #           K       ^       b                   =           mouse                   K                   E

                        ^       b                                               (Window Manager)                                                            `                       9           `                           |                   ~           n               3           xterm
    \olwm &"                                      OK                                    .                                                                                                                                                                       Q                           |

\olwm" \mwm" (Motif Window Manager) \twm" (Tom's Window Manager) \olvwm"
(Open Look Virtual Window Manager)                                Window                                                                            K           |                                           {                           #                   B           b

Manager run                 3    (kill process)    Window Manager                               |       .               l   *                                                                                                                                                               y   P   /




        X Window                                .       &           .       3                       I       ^                               P                               display                                             I                           A                       ^           login
                        Q                                                   xterm                                                           rlogin                      ^                               matlab                                      3               ^                       X   |

    Q               .       matlab                          i                       %                       display             3       ^                                                       ^                       9           `                                                               9

    I       ^                   !       8           )                                                           .               P                       .                       display                                             2       ]                                   .       #




    3       ^                           #                      window
                                                        "xhost + ^                                                  hostname"

                                    9                               ^         .  X                                                                                                  display
                                                        |               "xhost +"                                                                       `           #                   X       b                                   window



                                    9                               N   g       login                                                   g               ?                                       N   g                               P       K

                                    t       &                           #               ^                                                                       "xhost +                                ^                                   hostname"

    3       ^                                                           P                       .

                                                        "setenv DISPLAY                                             ^                       hostname:0"

                                    9                               ^                               .           X
                                    A                           ^   b       xhostT                      ^       '   DISPLAY

                                    Xlib: connection to "machineB:0.0" refused by server
                                    Xlib: Client is not authorized to connect to Server
                                    Error: Can't open display: machineB:0

                                            G           >




        &     \setenv"              \DISPLAY"              Shell                '                           (                                                               X       |               E                                                                                           3

        xterm ( cmdtool, shelltool) rlogin ( telnet)        T                 matlab                                                                                T                                                                   3

    v  matlab window display
            .                                   \setenv DISPLAY          hostname:0"                                                                            6                                                                                   ^

9              matlab   3     xterm                             xterm                                                               E       y       3                                           =           ^                                                                                   3

matlab       xterm        \setenv DISPLAY         hostname:0"                                                                                               ^                                                                                           R                                   %

.  \DISPLAY"        Shell                     Shell                   Shell                                     (                               3                                                                                           E                                           b




                                                                                                                                                        127
8.3. A Little More                                                                                                                Chapter 8. X Window System

        N xterm cmdtool shelltool              Shell Window                         K   }                                                 !           (                       1

        10 Window                   K       =           !           I       ^                     @               }                           9       F                               %

                3  Shell Window
                        P               \setenv DISPLAY           hostname:0"                                                 ^

       hostname                IP address
                                |                   ^                     Window                                      A               T           &           .

Y               #                            \xhost +"          ^X Server                                                     ^                                           w               ^

          hostname              3    X Window
                                        9             Server/Client                                                                                                       G       1       ^

                                ^                           3                   A X K                         4       Q                                   P           ^

Client(        )    OX Server(        )                                                      9            F               |



    b       m               &     X Window      |   :       :                                         h       9                   9                       A                               b

             X Window Guide           ftp.tem.nctu.edu.tw:/Chinese/X-UserGuide
                                                                        |       3                                                                                                 T       3

ftp.nctu.edu.tw:/Chinese/ifcss/software/x-win/x-win-guide.b5                                                                       0                              J       :   :           b

Q




                                                                                                  Question: How many Microsoft programmers
                                                                                                          does it take to change a light bulb ?
                                                                                                                               Answer: None.
                                                                                            The company just changes the standard to darkness.
                                                                                                                from NewsweekJuly, 11, 1994
                                                                                                                          by Andrew Schulman




                                                                                            128
Chapter 9



9.1            S        +                       b           (                               P




9                               f                                   ?                        8                                              K                |
                                                                                                                                                                                                                                                 1           9                                           +

    x               H                                               ]                       &                                   J                                                    T                           !           .                       B                       I       5                   P       K   !    b

manpage                     b           #           b               J                                   W                           A                                                    b       H                                       P                                                               \man
    ("                          1




TEX
L TEX
A                                   TEX                             p                                 Donald Knuth              .                                                                                                    (                       .               C           \       I       .

                                            n                                           \The Art of Computer Programming"                                                                                                                            9               h

                                            3                                                                       `                                        J                                                                                                                                                            X

                                    T           .                               I       *                           M               ^       b                                    h       ?       ?       :                    D                                              L                   3               .   P

                                            C                                           \       ?                           P               #                            X       |                                                                                       \   4                                   9

                                    TEX                                 2

                                                E       y       Z               }       P                                                                                .       P                                   4                   b   }                           8   F                                   2

                                    G           1977                O                       s           "                   TEX                          3                   B           &               W           !                               v                                   P                       ^

                                                b   L TEX
                                                     A          9   PC                                                                                                                                       b             EmTEX                                                                     9                   TEX
                                         Documentation                                                                  b               @           D                #                       #                       TEX             }       P                           Z                                       j   n

                                    DVI (DeVice Independent) format                                                                                                                  u       :                   b      \.tex" \.dvi"
                                                                                                                                                                                                                         |                               T                                               j       n

                                    W      TEX                  TEX                                                                                                                      Z       h       _                                                       6           _           ?       Z               /

                                         TEX                                                                                    1                                                                                K        G          4                               X               r               WYSIWYG
                                    (What You See is What You Get)                                                                                                           y                                       8                                       9               D                   P       L TEX
                                                                                                                                                                                                                                                                                                         A
                                      TEX               TEX                 /                       y                                                                        H                          Leslie Lamport                                                               .           J               W   f

                                            |           > L TEX
                                                           A            ]       P               -           W                                                h                                       L TEX
                                                                                                                                                                                                     A                           4




xdvi                                9                           :               DVI              j                          P                   Z                B                   TEX                                     |                                               j       n       }       P           \DVI"
                                    j                           |               \xdvi"3                         3           X Window                                                                                     preview                                     Q                   X               #


    1A                                  archie ftp                                  P                                   >                                b       n       9       ]                   1                                           B                   h           t       A                   6

1              0    2.4                 :
    2q    A        Knuth        >   0                       1                   \..... we wanted to produce documents that were not just nice, but actually the
best     :::   "
    3T        xdvik

                                                                                                                                                        129
9.1.   S   +      b       (                   P                                                                                                                                                                        Chapter 9.

                                                               T




dvips                                                 DVI              j               W               PS          j           n
                                                                                                                                       4

texi2dvi                                   Texi                        j              dvi  W                               j       n                   Texi                        GNU                                 Z                   }           P        8       n       ]


                      |       0       texinfo                  9                   GNU                                 P                   :           :




xlatex                            TEX \                _                   /   %                   0       %       /xdvi/dvips/                                                            "               K   J   )   3               R                            X Window
                              P




xv                                                                                 X Window                                                    P                       |                       :           TIFF GIF JPG                                         &                   j

                      n                           |                                &                           !                   format                                                          A          GIF PS    JPG                        T                        GIF

xautolock             9                   P                        |           3                               X Window idle                                                               `                                                                    K           "   8

                      `                                '                   (default                               5                    5




xnlock                xnlock                                                               lock screen                                                         P               lock screen                                     b                                                "

                      3               K                    M                                                                                   '                               message                             G                           P           )        q           ]   -

                              \xautolock                                   -locker xnlock                                                              "
x shtank                                                   X Window                                                    e                               Background                                          W                   e       X               b                e   *       *




xroach                9                                                            P                                           3               X Window                                    e               w       w                                                        N

                                                       ^




xantfarm                                               e                                       >               9                                   >               X   X       .                               e       *       W       >   w




Ghostscript Ghostscript(gs)       Postscript(PS)          \gs"                         v                                                                                                   P       +                           9                       P        |               3   ^

              Postscript Printer
                      b                          PS                                                                                                                                            j       n                        |                          PS   j

                      P      PS                   | GIF TIFF                                           j                   W                           }       P                       A                                                       j                            :

                     PS          image
                                  |       .       :                        W                                                               j                               8



                      % gs -sDEVICE=gif8 -sOutputFile=tiger.gif tiger.ps


ghostview             Postscript le                                                previewer                                                                           \gs" Postscript Language
xg                    X Window                                             i       %           8                               v                           8                   b           xgremlin tgif
xvgr                          %    8                               i           &                   `       a                       E                   A               ]                                   b               v                                                    gnu-
                      plot
gro                   GNU                         document formatting system                                                                                                       !               UNIX            tro             C       nro
                                                       manpage        PS                                                           W                           j                   A       :
                      % groff -man -Tps /usr/man/man1/cat.1 > cat.man.ps


elvis,vim                                             vi   8                           Z           h       _


  4T       \dvipsk"

                                                                                                                                                   130
Chapter 9.                                                                                                                                                                        9.1.            S       +               b       (           P




celvis           Z       vi       3        celvis                                   |                    Z




gcc/g++      GNU C/C++ Compiler
ispell           C   l            8




gzip         GNU Zip                                                            D                   P                                        j               \.gz"                        UNIX                                    D           P

              \compress"                                    D               P               \uncompress"                                         D                j               \.Z"                                gzip                |   D

              (gzip file                                        D                   gzip -d xxx.gz

gnuplot      Plotting             8                     ?                                   3                            %                   E   @       ~                    ]           J                       b




gnu t        gnu t                    gnuplot                   U                               |            curve tting
PSUtil               9                PS    j   n                       P               8                        A                   PS      j            5                                                                           PS      j

             n            ?                             t                                       \psselect"                                                            PS          j       5   W

                          |            6                        ]   -




psdraft                                    PS   j       n                               P                        |       .                           PS le                            N                                       \DO NOT
             COPY"            T                                                     C       3   e




pscount                               PS le                                                             \gs"                             @                                                    Shell Script
             #!/bin/sh
             # Count number of pages output from a postscript file by using
             # ghostscript (2.6.1pl4) specific device properties.
             # - Kevin Grover, grover@isri.unlv.edu, 9 Mar 1994
             #
             # to redefine ^D, use "(\004) cvn {} def"
             #
             (
             cat $*
             echo currentdevice /PageCount gsgetdeviceprop == flush
             ) | gs -q -sDEVICE=bit -sOutputFile=/dev/null -r5
             - | tail -1


cxterm           Z       \xterm"                        G       t                                        Z




cnprint                   Z                 P                   #           Big5                    GB                           }       P                    Z           D                           |       .       Z       j       W       PS
             j            A       :
             % cnprint -5W -f=k48 BIG5_file file.ps


mosaic                                     WWW server                           =       a           client                           P                                                                    \netscape"                          P




elm          9                                                                                  8                    f       F                           mail                     P       ?   ?                   W       A

                 F                    mail          P                           elm
pine         9                                                      8                   f       elm          ?                                       .                K           K




ftptool          3       X Window                                                   P       E                    ftp         8




                                                                                                131
9.2.                                                                                                                                                                                                Chapter 9.

perl                              Shell awk sed)                                                                               UNIX                +                                Larry Wall                    X       x

                       P   \patch"     news \rn"           C           \                                  P




nenscript                                          ASCII                       j       n         W        PS      j                P                   b                            \a2p"                     P                   !




bvi                    Binary vi                                                                 #    _               binary           j   n               _                            E           ]                 vi      v




mpeg2play                  D                                   w               mpeg              j    n           8




        #                  3           UNIX                                            :              j       n   (                9                   V               7       W            (   C         ^       b           E                   P




.ps                    Postscript                              j           n                         \gs"             :                     |               #                      postscript                                 ^           #




.eps                   Encapsulated Postscript                                                                j   n           Postscript                           j       n




.gz/.z                 GNUZIP                          D                                    j    n                        gzip (gnuzip)
.zip                   ZIP         j       n                                           unzip         9                P




.zoo                           zoo             9                               P




.shar                  Shell Archive                                                            unshar                         T                                        /bin/sh                 X    X




.tar                   UNIX                            #                                   tar
.hqx                   Macintosh                                   j           n                     binhex
.tgz                                               .tar.gz                                                            !   j    (       3       3               C               X    |               tgz                       gzip                    tar



9.2
|                              h                   Z                               b                                  |   0            :           :                   9                        b                                             h

    ]          3   h                   |                                                         0




        UNIX   C Shell Field Guide
        By Gail Anderson & Paul Anderson/Prentice-Hall
        9  C Shell Programming                                                                       h                                                                                  b           Z                 h                   >                 C
Shell                         C Shell program
                               C           A                                                                                                                               C Shell                                                    9       h        r

The Bible (of C Shell)
                                                                                                                              132
Chapter 9.                                                                                                                                                                                                                                                                            9.2.

        Zen and the Art of the Internet
        A Beginner's Guide to the Internet, First Edition, By Brendan P. Kehoe
        9               h                                                                        J                                   /                       1           0                                        3           Internet                                            $                   9           h

K   b               \
                    @         "                   96                                                                                     h                           b                                                        |                   D                                   \                           |

     ftp leica.ccu.edu.tw:/pub/internet/docs/zen-1.0/zen
                    3                                                                                                                                                                                                                                                      1994 8         O           `       8   ^

    \Newsweek"            \The Birth of the Internet"   b                   S       (                                                                                                             Z       a                                   +                           \Internet"
        \Internet"
            E                                                   b                                            |   0               \




        Big Dummy's Guide to the Internet
        A round trip through Global Networks, Life in Cyberspace, and Everything: : : , (by EFF)
        A               1                                   h                                c                   P                                                   c                                                        9                           R                   250                 W

                            E                                       K                                                    4   Q               |       Y                                                        E                           9                   h       )                               P           A

    1       \Zen and the Art of the Internet"                                                                                        c                                   9            h               E                                                       i                   *               8   /

            (   |             ftp.e .org:/pub/Net info/Guidebooks
                                                    Z                                                                                                                                                                                     )

        Internet                        @               W                           by
                ?       \       z           Z                                   9                                            X                       \Internet                            @               W               "                       |           3       h       7   0               T

J   (ftp.nctu.edu.tw:/Chinese/YuanInfo)

        The Cuckoo's Egg
        Tracking a Spy through the Maze of Computer Espionage, By Cli ord Stoll / Doubleday
                                @                                                        Cli Stoll                               \                                           (Accounting) 75                                                          5                                                           _

                                                                    n               3            h                       :                                   3                                O       D               A                   D                           G                               Y

.                           ^       x                                                            2                                                                       :                            F       Z       .                   A                   $                   9           0

8                                                                           #                                    FBI CIA                 |       C           KGB                      E               \                           C           Computer Security                                           b

                    |       :                   :               1           J                            A                                       "       Z                    h           ?
                                                                                                                                                                                                                                      5


        The Worm Story
        Communications of the ACM, June 1989, Vol. 32, number 6
                                                            \           H                                            A           w                                                P                   Internet                                                0       l       P       ^               ^

    w                       &          \ "    sendmail
                                                %                           &       _                                                                                        bug                                                          Internet                                                ^

                    Robert Tappan Morris, Jr.                                                                        9                                           .            @       ~                       9       w                               x       C                               P

                                    Robert Morris, Sr.                  l                                                                                Q                                H                               c           J               \           I       .                           j           (

            \       H                                   :::

        9                       I       P                   1                            O           G                   t   &                       @




        Cyberpunk (                                                 \       S            )

    59              h                               ^                                        #




                                                                                                                                                         133
9.2.                                                                                                                                                                                                                                                                Chapter 9.

                Z                             F                           *                                            (ps.                    &           )                                    0                                                                   t           (        \          "   J

Q                        G                                                    (The Worm)                                       |       C               Cli Stoll                                    8                                                                                       A      (Hannover
Hacker)                      :        :       9               h                   &            |                                                                       H                                            P                   h                   x                                   Kevin Mitnick
3   *      1995
            O                                     O               `                                                        Y               `                                                                        9                                       9                   31              O         \AD

cyberthief who couldn't stop himself"                                                                                                                                  /                                                1995                        O               2   `        27     ^                   Y           `

  (Newsweek)

        Life With Unix/A Guide for Everyone
        By Don Libes & Sandy Ressler / Prentice Hall
        9                                     UNIX                                         h                                       9                                               |                        :                   :                                           W                       h               /

    |                                     X                   ^           W                    b       n           UNIX                                                    F               1            ,                           3           9               h                   |                           n           UNIX
    W                   W        K                        z   a                                h                                       \




        The UNIX -HATERS Handbook
        By Simson Gar nkel, Daniel Weise & Steven Strassmann / IDG Books
        .                                      UNIX                                                                E                               A                                                        ^       n                                                                                                   v       b

            T                                 h                           a           UNIX

                             E            UNIX                                    K                                            :       :           9                   h                                                                UNIX                                                                        \   9           h

                            Donald A. Norman                                                       3       9           h                   G               1                   ?




                I remain suspicious: would anyone have spent this much time and e ort
                writing about how much they hated Unix if they didn't secretly love it? I'll
                leave that to the readers to judge, but in the end, it really doesn't matter: If
                this book doesn't kill Unix, nothing will.

        a       :::              K         UNIX                                                                    E   D               F                b                      OS                       ^       9               v           5




        The GAWK Manual
                .       \awk"                                                          h                                                                               9                                Richard Stallman                                                                            _                               W

            4       Q             j       E       GNU AWK                                      X                               )                       .                                        n                           h                   @       "                               8       /                           (
GNU                     ftp site                  T                   K       b                    A           ftp.nctu.edu.tw:/UNIX /gnu)

        GNU Manifesto
                                 GNU              C           Richard Stallman                                                                                     F                   t       ?                ]                                GNU            J                                   s                   1           Z

                                 |        3                       D GNU   w    ftp site                8                                                           0                                    b                   S           Richard Stallman                                            #               BYTE
*                   "   /                                                 \         1991                           #   G               *                                   O                   12       `   r           b                  \Stallman
                                                                                                                                                                                                                                            S                                                                           8           t

&   "       E       GNU               b               K               +                    E                   h                   a                           W                   b                                Q



        A                    |                        mosaic                           http://www.cs.pdx.edu/ trent/gnu/                                                                                                                                    :       :   b       n       GNU                     Z




                                                                                                                                                               134
Chapter 9.                                                                                                                                                                                                                      9.3.    e       1




                \                               *           t       &           t       B       z                   t       "       >   t                                   U                           |                   |   t   "   >

t   &                               .                           .                                       3                               BBS                     ?           Net News                i       K   b       D           UNIX
                                                    |                                               &                   D       D           .               ?   {               UNIX        *



                                3       ftp.csie.nctu.edu.tw:/pub/CSIE/contrib/cfaq/unix                                                                                                    b                   UNIX       FAQ
    3                               s               G                       \                                   :       :                           |                                   !                               README              j

                                    |                                       8       n                           Z                                                   :



        n       y       3               UNIX                                                Z                                               |       3           ftp.csie.nctu.edu.tw:/pub/Chinese/chinese-
text/big-faq                                                    I       5




9.3                 e                   1




    h                               8   n   e                   1           :

    Y               Z                                                                                       X11R5 + CXTERM 5.0
    Y               Z                                                                                       CXTERM                                                      + celvis (Chinese VI)
    Y       4                                                                                               L TEX2" + CJK + dvips
                                                                                                            A

    Y                       ^           C                                                                   Sparc10 with SunOS 4.1.3
                                                                                                            HP 9000/735 with HP UX/9.05
    Y       TEX         C       l               /       _                                                   TTF2PK


9.4 Finale
                                                            W                           h       T                   P                           I       5       UNIX                            m       \                   u   b

T                                   0   8   n                   h




        Q                       9                           I                           `       ^           b       `                                   T           h   9   9   K   K                               F       Q           A

9                       &                                                                   :::




                                                                                                                                                                                                            It's funny.
                                                                                                                                                                                    Don't ever tell anybody anything.
                                                                                                                                                                            If you do, you start missing everybody: : :
                                                                                                                                                135
9.4. Finale                     Chapter 9.

                               from The Catcher in the Rye
                                         by J. D. Salinger




Isn't this where : : :




                         136