Introduction to Unix - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

Introduction to Unix

Description:

They can consist of letters digits and Underscores. The first character cannot be a digit. ... Sample Numeric Array Declaration ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 29
Provided by: richard500
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Unix


1
Introduction to Unix
  • Class Room 336
  • Instructor Anthony Richards

2
The C Shell
  • A command interpreter
  • A high-level programming language

3
Accessing Shells
  • csh for C Shell
  • sh for Bourne Shell
  • jsh for Job Shell
  • ksh for Korn Shell
  • ps to display process status and shell

4
Some C Shell Features
  • History - Keeps a list of recent commands
  • Alias - Allows renaming of commands
  • Job control - move jobs to background or
    foreground
  • Directory Stack - keeps a list of dirctories
    and allows easy movement between them

5
History
  • history displays a list of recent commands
  • set history n instructs the shell to save the
    number of events specified by n.
  • set savehist n directs the shell to make the
    number of commans specified by n available across
    sessions.

6
Reexecuting Events
  • !n reexecutes the event specified by n
  • !! reexecutes the previous event
  • ! -5 executes the fith preceeding event

7
Modifying Previous Events
Space
  • place a and an a modifier after an event number
    in order to modify it.
  • !!s/car/cat will replace car with cat in the
    most recent event and execute it.
  • can be used to referr to the most recent event.
  • carcat also replaces car with cat in the most
    recent event.
  • page 349 event modifiers.

8
Aliases
  • provide short hand names for commands.
  • alias short hand actual command
  • allias ll ls -l will execute ls -l when ll is
    entered.
  • alias with no arguments will display a list of
    aliases.
  • unalias removes an alias.
  • alias alias name displays the command for the
    alias.

9
Job Control
  • runs a job or command in the background.
  • fg n moves the job specified by n from the
    background to the foreground.
  • To place a running job in the background
    stop the job
    with either stop of CTRL Z then type bg

10
Redirecting Standard Error
  • gt file name will redirect the standard error
    to the file specified by file name.

11
Filename Generation
  • The C Shell uses to generate filenames.
  • by itself expands to your home directory
  • username reffers to the home directory of the
    user specified in username.
  • cp letter.txt caax000 copies letter.txt tothe
    home directory of user caax000.

12
Filename Completion
  • command part of filename ESC will cause the
    shell to complete the file name.

13
Directory Stack
  • The directory stack is a list of directories in
    use.
  • The directories can be accessed and manipulated
    with teh pushd and popd commands.
  • dirs displays the list of directories in use. It
    displays working directory if the stack is empty.

14
pushd
  • pushd (push directory) provides an easy way to
    navigate between directories.
  • pushd directory changes to directory and places
    it at the top of the stack.
  • pushd with no arguments makes the second
    directory in on the stack the working directory
    and places that directory at top of stack.

15
Stack Numbers
  • Directories on the stack are numbered from 0,
    the top directory to nn, the total number of
    directories.
  • pushd n will move to the directory specified by
    n and place it at the top of the stack
  • popd (pop irectory) removes a directory from the
    stack

16
popd continued
  • popd removes the directory at the top of the
    stack.
  • popd n removes the directory specified by n from
    the stack.

17
Variables
  • variable names can be up to 20 characters in
    length.
  • They can consist of letters digits and
    Underscores.
  • The first character cannot be a digit.

18
Variable Types
  • String Numeric calculations cannot be performed
    on them
  • Numeric Numeric calculations can be performed on
    them.

19
Variable Declaration and Assignment
  • set variable name value declares a string
    variable and assigns the value to it.
  • set name sue spaces are allowed betwen the
    in the c shell
  • set variable name initializes the variable to a
    null string
  • set name
  • unset variable name removes the variable name
    from the declared variable list.

20
Variable Declaration Continued
  • set with no arguments displays the list of
    declared variables and their values.

21
Arrays of String Variables
  • set array variable name ( array element values
    ) declares a string array variable and assigns
    values to its elements.
  • set colors (red green blue orange yellow)
  • array variable namen references the nth element
    of array variable name
  • echo colors5
  • set colors3 purple
  • echo colors2-4

22
Numeric Variables
  • _at_ variable name operator expression declares a
    numeric variable and assigns a value to it.
  • The assigned value must be numeric.

23
Sample Numeric Assignments
  • _at_ count 0 assigns 0 to count
  • _at_ count ( 5 2) count is 7
  • _at_ result ( count lt 5) returns 0 because count
    is gt 5
  • _at_ count 5 adds 5 to count
  • _at_ count adds 1 to count
  • _at_count-- subtracts 1 from count

24
Numeric Arrays.
  • must be declared with set before values can be
    assigned.
  • values can be assigned to entire array or to
    single elements.
  • The index must be a numeric constant or a numeric
    variable. It cannot be an expression.

25
Sample Numeric Array Declaration
  • set ages (0 0 0 0 0) declares an array called
    ages with five elements.
  • _at_ ages2 15 assigns 15 to second element
  • _at_ ages3 (ages2 4)

26
Braces
  • use braces to separate a variable from other text
    without using spaces.
  • set prefix Alex
  • echo prefix is short for prefixander

27
Special Forms of User Variables
  • variable name gives the number of elements
    in an array
  • ?variable name returns 1 if the variable has
    been declared and 0 if it has not been declared

28
Lab 6Due November 24
  • page 380 1-7
Write a Comment
User Comments (0)
About PowerShow.com