|Student Learning Outcomes -|
- A successful student will be able to code basic commands in the BASH programming environment using a structured approach that shows mastery of the write/test/debug cycle. In particular, the student will be able to use arrays, iterative and conditional structures, sorts, regular expressions and nesting in shell scripts.
- A successful student will be able to make us of redirection, pipes, advanced regular expressions, awk, jobs, signals and other advanced scripting techniques.
|Description - |
|Linux shell script programming using the Bourne Again shell programming language (bash) and UNIX utilities to create practical shell scripts. Topics covered include customizing the environment, running and writing scripts, variables, loops, functions, text processing and debugging.|
|Course Objectives - |
|The student will be able to: |
- Describe the history, purpose and components of a UNIX shell.
- Create a user account, logon and get information using commands on a UNIX system.
- Understand and customize the bash shell environment by creating aliases and altering environment files.
- Use a UNIX text editor to create a shell script and run scripts effectively from the command line.
- Write code to redirect input and output to and from the user, files and commands using redirection and pipes.
- Incorporate essential UNIX utilities such as eval, exec, exit and sleep in a program.
- Describe the different types of variables in the bash environment and explain the properties and uses of each.
- Define, analyze and code the basic conditional and iterative control structures and explain how they can be nested.
- Design, implement, test, and debug functions that can be used in scripts, and demonstrate the way parameters are passed in such functions.
- Declare and initialize an array, then access and sort the array elements.
- Use regular expressions and bash commands to write code to process text including finding, sorting, comparing and merging.
- Use advanced regular expressions as well as the sed and awk utilities to perform more advanced text manipulation.
- Describe methods for handling and using processes, jobs, signals, coroutines, and subshells.
- Implement code to appropriately handle errors and provide meaningful feedback via exit status and error messages.
- Use a variety of techniques such as debug functions, debug statements and built in debugging options to find and fix code errors.
|Special Facilities and/or Equipment - |
- Access to a computer laboratory with the Linux operating system.
- A website or course management system with an assignment posting component (through which all lab assignments are to be submitted) and a forum component (where students can discuss course material and receive help from the instructor). This applies to all sections, including on-campus (i.e., face-to-face) offerings.
- When taught via Foothill Global Access on the Internet, the college will provide a fully functional and maintained course management system through which the instructor and students can interact.
- When taught via Foothill Global Access on the Internet, students must have currently existing e-mail accounts and ongoing access to computers with internet capabilities.
|Course Content (Body of knowledge) - |
- Shell Basics
- Purpose of a shell
- History of UNIX shells
- Components of UNIX
- The kernel and subsystems
- Getting started with UNIX
- How to login and logout
- User accounts
- The superuser
- Account settings and configuration
- Commands for getting information
- Stopping a program
- Customizing the Environment
- .bash_profile file
- .bash_logout file
- .bashrc file
- Shell prompt
- Writing and running scripts
- Text editors
- Understanding man pages
- Command line syntax
- Arguments and options
- Command line history
- Command line completion
- Command line editing
- Input / Output
- Standard input
- Standard output and Standard error
- Essential utilities/commands
- echo and print
- Bash reserved variables
- Typed variables
- Integer variables and arithmetic
- String variables and quoting
- Variable scope
- Exporting variables
- Program Control
- Logical operators
- Test command
- Functions and argument passing
- Writing functions
- Calling functions
- Positional parameters
- Processing options
- Text Processing Commands
- Selecting using grep
- Basic regular expressions
- Sorting input
- Finding files
- Merging lines
- Comparing files
- Eliminating duplicate lines
- Advanced Text Manipulation
- Advanced regular expressions
- Process Handling
- Process IDs and job numbers
- Job control
- Process substitution
- Exit and Signal handling
- Signal trapping
- Exit status
- Error messages
- Debugging Techniques
- Syntax vs. logic errors
- Echo commands
- Set built in debugging options
- Debug statements
- Debug functions
- Repeatability - Moved to header area.
|Methods of Evaluation - |
- Tests and quizzes
- Written laboratory assignments which include source code, sample runs and documentation.
- Final examination
|Representative Text(s) - |
|Cameron Newham, Learning the bash Shell: Unix Shell Programming, O'Reilly, 2010 |
Quigley, Ellie, Linux Shells by Example, Fourth Edition, Prentice Hall, 2005, ISBN: 013147572x
Tansley, David, Linux and UNIX Shell Programming, Addison Wesley, 2001.
Robbins, Arnold, Michael Brennan, Effective awk Programming, 3rd Edition, O'Reilly & Associates, Inc., 2001.
Aho, Alfred V., Brian W Kernighan, Peter J Weinberger, The AWK Programming Language, third edition, Addison-Wesley, 1999.
|Disciplines - |
|Computer Science |
|Method of Instruction - |
- Lectures which include motivation for syntax and use of shell programming language and shell scripting concepts, example programs, and analysis of these programs.
- On-line labs (for all sections, including those meeting face-to-face/on campus) consisting of
- An assignment web-page located on a college-hosted course management system or other department-approved Internet environment. Here, the students will review the specification of each lab assignment and submit their completed lab work.
- A discussion web-page located on a college hosted course management system or other department-approved Internet environment. Here, students can request assistance from the instructor and interact publicly with other class members.
- Detailed review of written assignments which includes model solutions and specific comments on the student submissions.
- In person or on-line discussion which engages students and instructor in an ongoing dialog pertaining to all aspects of designing, implementing and analyzing shell scripts.
- When course is taught fully on-line:
- Instructor-authored lecture materials, handouts, syllabus, assignments, tests, and other relevant course material will be delivered through a college hosted course management system or other department-approved Internet environment.
- Additional instructional guidelines for this course are listed in the attached addendum of CS department on-line practices.
|Lab Content - |
- Getting started with UNIX
- Create a new user account with user id and password.
- Enter commands such as whois, which and whereis to get basic information.
- Run and stop programs from the command line.
- Customize the environment by altering key system files.
- Writing and running scripts
- Demonstrate the complete edit-debug-run cycle of a script using a text editor and the command-line environment.
- Use command line arguments and options to run the script.
- Distinguish between syntax errors and logic errors and develop strategies for dealing with each type of error.
- Debug code with the help of error messages and functions to produce a working program.
- Exploring the different variable types through system and user-written files
- Gain experience in effectively using the text editor to create code with numeric types.
- Gain experience in effectively using the text editor to create code with string types.
- Use the text editor to assist in assigning new values to bash environment and reserved variables.
- Solve syntax and logic problems that arise from typical incorrect use of variables whether pre-defined or user-defined.
- Demonstrating interaction with the user, files and commands
- Use pipes and redirection to interact with files or other commands.
- Play the role of user and programmer, alternately, to establish a user-interaction plan for a program.
- Evaluate and comment on other students' user-interaction plan.
- Change modes from source code design (editing mode) to end-user interaction (run mode) in your IDE in order to perform Q/A on the program.
- Fix poor interaction behavior by adjusting code and rerunning program until a satisfactory result is achieved.
- Building a script that demonstrates “intelligence” though a combination of control statements
- Become familiar with selection, loop and nesting to imbue code with correct logic behavior.
- Use structured programming to make control structures maintainable.
- Run the program multiple times to verify that its control statements produce the correct behavior or output under any scenario.
- Fix incorrect logic behavior by adjusting control structures and rerunning program until a satisfactory result is achieved.
- Incorporating functions and utilities in programming projects
- Gain experience in writing a function.
- Use a previously written function/utility in a client program.
- Refine functions by adding or changing their definitions and observe the result.
- Use positional parameters and processing options to change the outcome of running a function.
- Deduce the impact of a function's or utility's design on the programs that invoke it.
- Processing and manipulating text.
- Use commands, regular expressions, and utilities such as sed and awk to process and manipulate text.
- Use the man pages to understand the purpose and use of various text processing commands.
- Use debugging techniques to successfully integrate awk and sed functions into user written code.
- Handling processes
- Use a text editor to write code involving both system and user processes.
- Incorporate commands to control jobs, handle signals, run coroutines and start child processes.
- Show results by using commands to print information on processes.
- Use debugging techniques to solve problems that arise during the testing of the program.
|Types and/or Examples of Required Reading, Writing and Outside of Class Assignments - |
- Textbook assigned reading averaging 30 pages per week.
- Reading the supplied handouts and modules averaging 10 pages per week.
- Reading on-line resources as directed by instructor though links pertinent to bash shell scripting.
- Reading library and reference material directed by instructor through course handouts.
- Writing technical prose documentation that supports and describes the programs that are submitted for grades.