City College of San Francisco
Course Outline of Record
Course Status: Active
I. GENERAL DESCRIPTION
A. Approval Date November 2015
B. Effective Semester Fall 2016
C. Department Computer Science
D. Course Number CS 160B
E. Course Title Unix/Linux Shell Scripting
F. Course Outline Originator Gregory Boyd
G. Department Chairperson Craig Persiko
H. Dean David Yee
II. COURSE SPECIFICS
A. Hours
Lecture: 35
Homework: 70
Total Hours: 105
B. Units 2
C. Prerequisite None
    Corequisite None
    Pre/Corequisite None
    Advisory CS 160A
    Advisory Pre/Corequisite None
D. Course Justification System administration jobs require shell scripting skills. This course will bring a student's shell scripting skills to a level that will help prepare them for CS 260A and for the shell scripting needed for CS 211D and the database administration courses.
E. Field Trips No
F. Method of Grading Letter or Pass/No Pass
G. Repeatability Course is not repeatable
III. CATALOG DESCRIPTION
Analyze, design, write, test, and debug shell scripts. Students learn basic shell scripting techniques and develop scripting skills needed for Unix/Linux System Administration courses. The bash shell is used.
IV. STUDENT LEARNING OUTCOMES
Upon completion of this course, a student will be able to:
  1. Use command substitution to capture program output.
  2. Use conditional statements to control the execution of shell scripts.
  3. Write shell scripts to perform repetitive tasks using while and for loops.
  4. Design and implement shell functions.
  5. Identify and process command-line arguments.
V. CONTENTS
  1. Review of Basic Unix Concepts
    1. Shell differences
    2. Script basics
    3. Working with files and directories
    4. Using find to locate files and directories by name pattern and type
    5. Manipulating file attributes: owners, groups and permissions.
    6. Using text filters such as head, tail, cut, tr, sort, uniq, grep, sed and awk.
    7. Basic regular expressions
  2. Shell Programming
    1. Script Basics
    2. Variables
      1. local
      2. environment
    3. Substitution
      1. shell wildcards
      2. variable
      3. command, including backquote and $(...) forms
      4. arithmetic, including expr and $((...)) forms
    4. Quoting
      1. backslashes
      2. single quotes
      3. double quotes
      4. quoting rules
    5. Flow Control
      1. the test command
      2. the if statement
      3. the case statement
      4. conditional operators && and II
    6. Loops
      1. the for loop
      2. the while loop
      3. break and continue
    7. Documentation
      1. Comments
      2. Indentation
    8. Parameters
      1. special variables ($#, $*, $0, $1 ...)
      2. options and arguments
      3. using 'set' to set command line arguments
      4. command-line option parsing in shell scripts
    9. Input/Output file descriptors and redirection in scripts
      1. standard input, standard output, and standard error
      2. output redirection, including: >  2>   >>  and  2>>
      3. input redirection, including < and <<
      4. combining output streams using:   2>&1   >&2
      5. using the read command to read data from files and interactively from the user
    10. Functions
      1. creating and using functions
      2. scoping issues
    11. Miscellaneous Topics
      1. re-evaluation of the command using eval
      2. the null command (:)
      3. using type to show how commands are resolved
      4. using sleep to implement delays
      5. use of temporary files with unique filenames generated using $$ or mktemp
      6. creation and use of variables containing file paths
      7. sourcing using the . (dot) operator
  3. Advanced Topics
    1. Debugging
      1. shell tracing
      2. adding conditional debugging code
    2. Function Libraries
      1. creating a library of functions
      2. useful functions
    3. Steps in designing a script
    4. Techniques for increasing portability
 
VI. INSTRUCTIONAL METHODOLOGY
  1. Assignments
    1. In-class activity: Group coding of example shell scripting problems
    2. In-class activity: Analyzing existing shell scripts
    3. Out-of-class assignment: Creating shell scripts that use text filters to filter the output of Unix commands, analyze the results, and report findings to the user
    4. Out-of-class assignment: Combining redirection, conditionals, and looping in a script.
    5. Out-of-class assignment: Writing several functions and including them in a script
    6. Out-of-class assignment: Writing scripts that use and analyze arguments to perform their tasks as do standard Unix/Linux commands.
  2. Evaluation
    1. Written work: Student assignments as described above that measure the student's ability to understand Unix/Linux shell scripting, filter text, and use Unix utilities, control structures, redirection, and functions to effectively analyze problems and solve them with shell scripts.
    2. Exams/Quizzes/Tests: Periodic tests that measure the student's ability to understand concepts, such as: shell variables, command and arithmetic substitution, quoting rules, how to use regular expressions and text filters to filter text, shell control structures, functions, redirection, problem solving, and portability issues.
    3. Final Assessment: Comprehensive final exam that measure the student's ability to understand concepts, such as: shell variables, command and arithmetic substitution, quoting rules, how to use regular expressions and text filters to filter text, shell control structures, functions, redirection, problem solving, and portability issues.
  3. Representative Textbooks and Other Instructional Materials
    1. Kochan and Wood. 2003. Unix Shell Programming (3rd edition). SAMS Publishing.
    2. Chris F.A. Johnson and Jayant Varma. 2015. Pro Bash Programming 2nd Edition. Apress.
    3. Class handouts such as practice exercises, assignments, or review notes
    4. Remote access to a Unix/Linux server.
VII. TITLE 5 CLASSIFICATION
CREDIT/DEGREE APPLICABLE (meets all standards of Title 5. Section 55002(a))