FUNCTIONSFunctions are used to reference a group of commands with a single name. They are more efficient to use than equivalent Bourne shell scripts, because once a function has been defined, it doesn't have to be read in from the disk again. Functions also provide a way to organize Bourne shell scripts into routines, like in other high-level programming languages. To be used, functions must be read in first, but can then be invoked like regular commands. For example, in Bourne shell scripts, functions are included at the top so that they are read in first. Environment functions can be put into a file and read in with the . command. Functions cannot be exported, so they are only available to the current shell. To exit from a function, but not from a Bourne shell script, use the return command. Functions are defined with the following format: name() { commands ; } RESTRICTED SHELLRunning under the restricted shell rsh is equivalent to sh, except that changing directories, setting the value of PATH, specifying path or command names containing /, and redirecting output with > or >> are not allowed. DEBUGGING BOURNE SHELL SCRIPTSThe Bourne shell provides a number of options that are useful in debugging scripts: n, v, and x. The n option causes commands to be read without being executed and is used to check for syntax errors. The v option causes the input to displayed as it is read. The x option causes commands in Bourne shell scripts to be displayed as they are executed. This is the most useful, general debugging option. For example, tscript could be run in trace mode if invoked "sh x tscript". FILES
REGULAR EXPRESSIONS
MISC COMMANDSThe following commands are frequently used in Bourne shell scripts to filter input and output. awk/nawkPattern Scanning and Processing Language $awk [ options ] [ 'program' ] [ parameters ] [ files ] $nawk [ options ] [ 'program' ] [ files ] Description: The awk/nawk command performs actions for lines in files that match patterns specified in program. Each input line is made up of fields separated by whitespace. Options:
|