Module Release August 2002: Advanced Shell Usage
This month's module release marks a small but necessary departure from our basic policy of progressing through the Linux Professional Institute (LPI) 101 exam objectives in the order they are published.
The module is designed to develop understanding and confident use of quoting and special characters in Unix shells. Its contents are not very ?advanced?, but the easy deployment of quotation and special characters does mark an important stage in the transition to advanced shell usage and is a pre-requisite for most system administration and shell programming tasks.
These topics were not included, or not included at this stage, in the LPI objectives, but GBdirect inserted them into their commercial LPI 101 course, because they are necessary preconditions for the four filesystem modules which follow. Since Linux Training Materials Project modules are largely derived from the GBdirect course, our releases adopt the same pattern.
Quoting is, in essence, a mechanism for controlling and exploiting the special meanings that some characters have for the command line interpreter (Bash), e.g. without quoting the shell interprets an asterisk as a match for almost any character at all (or none).
The module firstly explains how pairs of single quote marks can be used to prevent all the characters between them from being interpreted as special. Secondly it illustrates the use of a backslash to turn off the special meaning of single characters. Thirdly, it shows how pairs of double quotes can be used to turn off the special meaning of some characters whilst preserving the special meaning of others. Fourthly, the module shows how to combine the three methods when necessary (rarely).
Having demonstrated how to control characters' special meanings, the rest of the module concentrates on using those special meanings to get everyday jobs done quickly and simply, e.g. selecting small subsets of files and directories from within a complex filesystem, or generating new files programmatically. Finally, the module merely introduces the concept of shell programming without elaborating.
|