DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

Creating and using shell scripts



Automating frequent tasks
        Creating a shell script
                Running a script under any shell
                Writing a short shell script: an example
                Passing arguments to a shell script
                Performing arithmetic and comparing variables
                Performing arithmetic on variables in the Korn shell
        Sending a message to a terminal
                The echo command
                The print command (Korn shell only)
                More about redirecting input and output
        Getting input from a file or a terminal
                Reading a single character from a file or a terminal
                Attaching a file to a file descriptor
        What to do if something goes wrong
                Solving problems with the environment
                Solving problems with your script
                What to do if your shell script fails
        Writing a readability analysis program: an example
                How to structure a program
                Making a command repeat: the for loop
                Getting options from the command line: getopts
                Repeating commands zero or more times: the while loop
                Repeating commands one or more times: the until loop
                Making choices and testing input
                Choosing one of two options: the if statement
                Different kinds of test
                Testing exit values
                The && and || operators
                Making multiway choices: the case statement
                Generating a simple menu: the select statement
                Expanding the example: counting words
                Making menus
                Assigning variables default values
        Tuning script performance
        How programs perform
        How to control program performance
                Number of processes generated
                Number of data bytes accessed
                Shortening data files
                Shortening directory searches
                Directory-search order and the PATH variable
                Recommended ways to set up directories
        Putting everything together
                Readability analysis
                Extending the example
        Other useful examples
                Mail tools
                        Count the number of messages in MMDF mail folder
                        Print the header lines of every message in a folder
                        Mail a large file, in pieces
                File tools
                        Return the total size of a group of files
                        Compress a batch of files concurrently
                Useful routines
                        Locking files
                Context sensitive scripts

Regular expressions
        Literal characters in regular expressions
        Metacharacters in regular expressions
        Wildcard characters
        Editor regular expressions
                Escaping metacharacters
                Regular expression grouping
                Precedence in regular expressions
                Regular expression summary
        Korn shell regular expressions

Using awk
        Basic awk
                Fields
                Program structure
                Running awk programs
                Formatting awk output
        Variables
                Field variables
                Built-in variables
                User-defined variables
                Number or string?
                A handful of useful one-liners
        Error messages
        Patterns
                Using simple patterns
                BEGIN and END
                Relational operators
                Regular expressions
                Combining patterns
                Pattern ranges
        Actions
                Performing arithmetic
        Functions
                Using arithmetic functions
                Using strings and string functions
        Control flow statements
                if statements
                while statements
                for statements
                Flow control statements
        Arrays
                User-defined functions
                Some lexical conventions
        awk output
                The print statement
                Output separators
                The printf statement
                Output into files
                Output into pipes
        Input
                Files and pipes
                Input separators
                Multiline records
                Multiline records and the getline function
                Command-line arguments
        Using awk with other commands and the shell
                The system function
                Cooperation with the shell
        Spanning multiple lines
        Example applications
                Generating reports
                Word frequencies
                Accumulation
                Random choice
                Shell facility

Manipulating text with sed
        What is sed?
        Using sed
                Writing sed commands
                How sed commands are carried out
        Addresses
                Line addresses
                Context addresses
        Functions
                Whole-line oriented functions
                Substitute functions
                The transform function
                Input-output functions
                Multiple input-line functions
                Hold and get functions
                Flow-of-control functions
                Comments in sed
                Miscellaneous functions

Index