The course is designed to teach techniques that facilitate scripting for UNIX / LINUX OS versions, which are the most popular with customers.
Məqsədlər
Objectives
The program includes fundamental knowledge about:
command shells and editors;
basic programming concepts in these operating environments.
Tələblər
Intended Audience
Advanced users
System and network administrators
Prerequisites
General training in commercial or free distribution of UNIX or LINUX.
Programming experience is a plus.
Kursun proqramı
Outline
Module 1. History and flavours of command-line shells. POSIX standard for shells.
History of shells: Thomson’s sh, rc, Bourne, Korn, California (csh)
POSIX standard for shells.
Modern shells: Bourne Again (bash), zsh, tcsh, tclsh
Module 2. VI editor as a fundamental for UNIX shells operation.
History of editors: ed, em, ex, vi, sed, vim, emacs
Operation modes of VI editor, using command mode hot keys.
I Improved for GNU/Linux.
Module 3. Command line editing in shells.
What is a terminal? Terminal capabilities and behaviour: terminfo command
vi vs emacs mode, using control keys in different modes.
Readline in GNU/Linux
Module 4. Basic UNIX and GNU tools for command line operation
Working with documentation system, navigating and operating file system, searching files and content, hardware information, users information, working with processes.
Module 5. Shell Scripting fundamentals.
What is script?
Which shell should interprets script.
Script format.
Comments in scripts.
Portability issues.
Module 6. Variables
A concept of variables. Environment vs Local variables.
Variables substitution, conditional substitution.
Removing variables.
Shell built-in and special variables.
Module 7. User Input
Requesting user input: read command.
Positional parameters (command-line arguments).
Creating parameters. Shifting parameters.
Module 8. Designing program output
Basic output: echo vs print
Formatted output: printf
Advanced formatting in the terminal: tput
Module 9. Shell Arithmetic
Math in shell — integer operations.
Base10, Base2 and other radix.
Working with arithmetic. Operators.
Floating-point math using bc tool.
Module 10. Filename generation patterns
Mass operations on files.
Available patterns.
Filename globbing.
Module 11. Branches and Logic Testing
A concept of Return status
Logic testing: test command
Program flow branching constructs: if .. then .. elif .. else and case statements
Module 12. Program loops
The while and until conditional loops.
The for iteration loop.
The select loop.
Breaking a loop (continue, break, exit).
Module 13. The getopts Command
Parsing command-line options inside a script: getopts command.
Special shell variables OPTIND and OPTARG.
Enhanced option parsing: getopt. getopt vs getopts.
Module 14. Array Variables
Integer-indexed arrays.
Substituting and counting all elements.
Bash-style hash maps.
Module 15. Functions and Function Libraries
A concept of a shell function.
Displaying and declaring functions. Variable scope.
Function execution flow. return command.
Korn-style function libraries.
Module 16. Managing Input and Output
A concept of file descriptors. Data flow through a process.
Managing file descriptors. Special invocation of exec command.
Passing file contents to a script. Redirecting to a loop within script.
Using here-documents.
Module 17. Traps and Signals
A concept of signals. Common and well-known signals.
Handling a signal: trap command.
Controlling generation of signals from terminal: stty command.
Module 18. Regular Expressions
A concept of regular expressions.
Metacharacters and escaping. Different flavours of regular expressions syntax.