Previous Section  < Day Day Up >  Next Section

   
  
• Table of Contents
• Index
• Examples
UNIX® Shells by Example Fourth Edition
By Ellie Quigley
 
Publisher: Prentice Hall PTR
Pub Date: September 24, 2004
ISBN: 0-13-147572-X
Pages: 1200
   


   Copyright
   Preface
      ACKNOWLEDGMENTS
      Chapter 1.  Introduction to UNIX/Linux Shells
      Section 1.1.  What Is UNIX? What Is Linux? A Little History
      Section 1.2.  Definition and Function of a Shell
      Section 1.3.  History of the Shell
      Section 1.4.  System Startup and the Login Shell
      Section 1.5.  Processes and the Shell
      Section 1.6.  The Environment and Inheritance
      Section 1.7.  Executing Commands from Scripts
      Chapter 2.  Shell Programming QuickStart
      Section 2.1.  Taking a Peek at Shell Scripts
      Section 2.2.  Sample Scripts: Comparing the Major Shells
      Section 2.3.  The C and TC Shell Syntax and Constructs
      Section 2.4.  The Bourne Shell Syntax and Constructs
      Section 2.5.  The Korn Shell Constructs
      Section 2.6.  The Bash Shell Constructs
      Chapter 3.  Regular Expressions and Pattern Matching
      Section 3.1.  Regular Expressions
      Section 3.2.  Combining Regular Expression Metacharacters
      Chapter 4.  The grep Family
      Section 4.1.  The grep Command
      Section 4.2.  grep Examples with Regular Expressions
      Section 4.3.  grep with Options
      Section 4.4.  grep with Pipes
      Section 4.5.  egrep (Extended grep)
      Section 4.6.  fgrep (Fixed grep or Fast grep)
      Section 4.7.  Linux and GNU grep
      Section 4.8.  GNU Basic grep (grep –G) with Regular Expressions
      Section 4.9.  grep –E or egrep (GNU Extended grep)
      Section 4.10.  Fixed grep (grep –F and fgrep)
      Section 4.11.  Recursive grep (rgrep, grep –R)
      Section 4.12.  GNU grep with Options
      Section 4.13.  grep with Options (UNIX and GNU)
      LAB 1: grep EXERCISE
      Chapter 5.  sed, the Streamlined Editor
      Section 5.1.  What Is sed ?
      Section 5.2.  Versions of sed
      Section 5.3.  How Does sed Work?
      Section 5.4.  Regular Expressions
      Section 5.5.  Addressing
      Section 5.6.  Commands and Options
      Section 5.7.  Error Messages and Exit Status
      Section 5.8.  Metacharacters
      Section 5.9.  sed Examples
      Section 5.10.  sed Scripting
      LAB 2: sed EXERCISE
      Chapter 6.  The awk Utility
      Section 6.1.  What's awk? What's nawk? What's gawk?
      Section 6.2.  awk's Format
      Section 6.3.  How awk Works
      Section 6.4.  Formatting Output
      Section 6.5.  awk Commands from Within a File
      Section 6.6.  Records and Fields
      Section 6.7.  Patterns and Actions
      Section 6.8.  Regular Expressions
      Section 6.9.  awk Commands in a Script File
      Section 6.10.  Review
      LAB 3: awk EXERCISE
      Section 6.11.  Comparison Expressions
      Section 6.12.  Review
      LAB 4: awk EXERCISE
      Section 6.13.  Variables
      Section 6.14.  Redirection and Pipes
      Section 6.15.  Pipes
      Section 6.16.  Review
      LAB 5: nawk EXERCISE
      Section 6.17.  Conditional Statements
      Section 6.18.  Loops
      Section 6.19.  Program Control Statements
      Section 6.20.  Arrays
      Section 6.21.  awk Built-In Functions
      Section 6.22.  Built-In Arithmetic Functions
      Section 6.23.  User-Defined Functions (nawk)
      Section 6.24.  Review
      LAB 6: nawk EXERCISE
      Section 6.25.  Odds and Ends
      LAB 7: nawk EXERCISE
      Section 6.26.  awk Built-In Functions
      Chapter 7.  The Interactiven Bourne Shell
      Section 7.1.  Introduction
      Section 7.2.  The Environment
      Section 7.3.  The Command Line
      Section 7.4.  Shell Metacharacters (Wildcards)
      Section 7.5.  Filename Substitution
      Section 7.6.  Variables
      Section 7.7.  Quoting
      Section 7.8.  Command Substitution
      Section 7.9.  An Introduction to Functions
      Section 7.10.  Standard I/O and Redirection
      Section 7.11.  Pipes
      Section 7.12.  The here document and Input
      Chapter 8.  Programming the Bourne Shell
      Section 8.1.  Introduction
      Section 8.2.  Reading User Input
      Section 8.3.  Arithmetic
      Section 8.4.  Positional Parameters and Command-Line Arguments
      Section 8.5.  Conditional Constructs and Flow Control
      Section 8.6.  Looping Commands
      Section 8.7.  Functions
      Section 8.8.  Trapping Signals
      Section 8.9.  The Command Line
      Section 8.10.  Shell Invocation Options
      LAB 8: BOURNE SHELL—GETTING STARTED
      LAB 9: METACHARACTERS
      LAB 10: REDIRECTION
      LAB 11: FIRST SCRIPT
      LAB 12: COMMAND-LINE ARGUMENTS
      LAB 13: GETTING USER INPUT
      LAB 14: CONDITIONAL STATEMENTS
      LAB 15: CONDITIONALS AND FILE TESTING
      LAB 16: THE case STATEMENT
      LAB 17: LOOPS
      LAB 18: FUNCTIONS
      Chapter 9.  The Interactive C and TC Shells
      Section 9.1.  Introduction
      Section 9.2.  The Environment
      Section 9.3.  The C/TC Shell Command Line
      Section 9.4.  Aliases
      Section 9.5.  Manipulating the Directory Stack
      Section 9.6.  Job Control
      Section 9.7.  Shell Metacharacters
      Section 9.8.  Filename Substitution
      Section 9.9.  Redirection and Pipes
      Section 9.10.  Variables
      Section 9.11.  Command Substitution
      Section 9.12.  Quoting
      Section 9.13.  New Features of the Interactive TC Shell
      Section 9.14.  The TC Shell Command Line
      Section 9.15.  TC Shell Command, Filename, and Variable Completion
      Section 9.16.  TC Shell Spelling Correction
      Section 9.17.  TC Shell Aliases
      Section 9.18.  TC Shell Job Control
      Section 9.19.  Printing the Values of Variables in the TC Shell
      Section 9.20.  TC Shell Built-In Commands
      LAB 19: THE TC SHELL—GETTING STARTED
      LAB 20: HISTORY
      LAB 21: SHELL METACHARACTERS
      LAB 22: REDIRECTION
      LAB 23: VARIABLES AND ARRAYS
      Chapter 10.  Programming the C and TC Shells
      Section 10.1.  Introduction
      Section 10.2.  Reading User Input
      Section 10.3.  Arithmetic
      Section 10.4.  Debugging Scripts
      Section 10.5.  Command-Line Arguments
      Section 10.6.  Conditional Constructs and Flow Control
      Section 10.7.  Looping Commands
      Section 10.8.  Interrupt Handling
      Section 10.9.  setuid Scripts
      Section 10.10.  Storing Scripts
      Section 10.11.  Built-In Commands
      LAB 24: C/TC SHELLS—GETTING STARTED
      LAB 25: SHELL METACHARACTERS
      LAB 26: REDIRECTION
      LAB 27: FIRST SCRIPT
      LAB 28: GETTING USER INPUT
      LAB 29: COMMAND-LINE ARGUMENTS
      LAB 30: CONDITIONALS AND FILE TESTING
      LAB 31: THE switch STATEMENT
      LAB 32: LOOPS
      Chapter 11.  The Interactive Korn Shell
      Section 11.1.  Introduction
      Section 11.2.  The Environment
      Section 11.3.  The Command Line
      Section 11.4.  Commenting and Filename Expansion
      Section 11.5.  Aliases
      Section 11.6.  Job Control
      Section 11.7.  Metacharacters
      Section 11.8.  Filename Substitution (Wildcards)
      Section 11.9.  Variables
      Section 11.10.  Quoting
      Section 11.11.  Command Substitution
      Section 11.12.  Functions
      Section 11.13.  Standard I/O and Redirection
      Section 11.14.  Pipes
      Section 11.15.  Timing Commands
      Chapter 12.  Programming the Korn Shell
      Section 12.1.  Introduction
      Section 12.2.  Reading User Input
      Section 12.3.  Arithmetic
      Section 12.4.  Positional Parameters and Command-Line Arguments
      Section 12.5.  Conditional Constructs and Flow Control
      Section 12.6.  Looping Commands
      Section 12.7.  Arrays
      Section 12.8.  Functions
      Section 12.9.  Trapping Signals
      Section 12.10.  Coprocesses
      Section 12.11.  Debugging
      Section 12.12.  The Command Line
      Section 12.13.  Security
      Section 12.14.  Built-In Commands
      Section 12.15.  Korn Shell Invocation Arguments
      LAB 33: KORN SHELL—GETTING STARTED
      LAB 34: HISTORY
      LAB 35: ALIASES AND FUNCTIONS
      LAB 36: SHELL METACHARACTERS
      LAB 37: TILDE EXPANSION, QUOTES, AND COMMAND SUBSTITUTION
      LAB 38: REDIRECTION
      LAB 39: JOB CONTROL
      LAB 40: WRITING THE info SHELL SCRIPT
      LAB 41: VARIABLE EXPANSION OF SUBSTRINGS
      LAB 42: THE lookup SCRIPT
      LAB 43: USING typeset
      LAB 44: THE if/else CONSTRUCT AND THE let COMMAND
      LAB 45: THE case STATEMENT
      LAB 46: THE select LOOP
      LAB 47: AUTOLOADING FUNCTIONS
      Chapter 13.  The Interactive Bash Shell
      Section 13.1.  Introduction
      Section 13.2.  The Environment
      Section 13.3.  The Command Line
      Section 13.4.  Job Control
      Section 13.5.  Command-Line Shortcuts
      Section 13.6.  Aliases
      Section 13.7.  Manipulating the Directory Stack
      Section 13.8.  Metacharacters (Wildcards)
      Section 13.9.  Filename Substitution (Globbing)
      Section 13.10.  Variables
      Section 13.11.  Quoting
      Section 13.12.  Command Substitution
      Section 13.13.  Arithmetic Expansion
      Section 13.14.  Order of Expansion
      Section 13.15.  Arrays
      Section 13.16.  Functions
      Section 13.17.  Standard I/O and Redirection
      Section 13.18.  Pipes
      Section 13.19.  Shell Invocation Options
      Section 13.20.  Shell Built-In Commands
      LAB 48: bash SHELL—GETTING STARTED
      LAB 49: JOB CONTROL
      LAB 50: COMMAND COMPLETION, HISTORY, AND ALIASES
      LAB 51: SHELL METACHARACTERS
      LAB 52: REDIRECTION
      LAB 53: VARIABLES
      Chapter 14.  Programming the Bash Shell
      Section 14.1.  Introduction
      Section 14.2.  Reading User Input
      Section 14.3.  Arithmetic
      Section 14.4.  Positional Parameters and Command-Line Arguments
      Section 14.5.  Conditional Constructs and Flow Control
      Section 14.6.  Looping Commands
      Section 14.7.  Functions
      Section 14.8.  Trapping Signals
      Section 14.9.  Debugging
      Section 14.10.  The Command Line
      Section 14.11.  bash Options
      Section 14.12.  Shell Built-In Commands
      LAB 54: bash SHELL—FIRST SCRIPT
      LAB 55: COMMAND-LINE ARGUMENTS
      LAB 56: GETTING USER INPUT
      LAB 57: CONDITIONAL STATEMENTS
      LAB 58: CONDITIONALS AND FILE TESTING
      LAB 59: THE case STATEMENT
      LAB 60: LOOPS
      LAB 61: FUNCTIONS
      Chapter 15.  Debugging Shell Scripts
      Section 15.1.  Introduction
      Section 15.2.  Style Issues
      Section 15.3.  Types of Errors
      Section 15.4.  Probable Causes for Syntax Errors
      Section 15.5.  Tracing with Shell Options and the set Command
      Section 15.6.  Summary
      Chapter 16.  The System Administrator and the Shell
      Section 16.1.  Introduction
      Section 16.2.  The Superuser
      Section 16.3.  Becoming a Superuser with the su Command
      Section 16.4.  Boot Scripts
      Section 16.5.  Summary
      Appendix A.  Useful UNIX/Linux Utilities for Shell Programmers
      apropos—searches the whatis database for strings
      arch—prints the machine architecture (see uname -m)
      at, batch—executes commands at a later time
      awk—pattern scanning and processing language
      banner—makes posters
      basename—with a directory name delivers portions of the pathname
      bash—GNU Bourne Again Shell
      bc—processes precision arithmetic
      bdiff—compares two big files
      cal—displays a calendar
      cat—concatenates and displays files
      chfn—changes the finger information
      chmod—changes the permissions mode of a file
      chown—changes owner of file
      chsh—changes your login shell
      clear—clears the terminal screen
      cmp—compares two files
      compress—compress, uncompress, zcat compress, uncompress files, or display expanded files
      cp—copies files
      cpio—copies file archives in and out
      cron—the clock daemon
      crypt—encodes or decodes a file
      cut—removes selected fields or characters from each line of a file
      date—displays the date and time or sets the date
      dd—converts a file while copying it
      diff—compares two files for differences
      dos, xdos, dosexec, dosdebug—a Linux DOS emulator that runs MS-DOS and MS-DOS programs under Linux
      df—summarizes free disk space
      du—summarizes disk usage
      echo—echoes arguments
      egrep—searches a file for a pattern using full regular expressions
      expr—evaluates arguments as an expression
      fgrep—searches a file for a character string
      file—determines the type of a file by looking at its contents
      find—finds files
      finger—displays information about local and remote users
      fmt—simple text formatters
      fold—folds long lines
      ftp—file transfer program
      free—displays amount of free and used memory in the system
      fuser—identifies processes using files or sockets
      gawk—pattern scanning and processing language
      gcc, g++—GNU project C and C++ Compiler (v2.7)
      getopt(s)—parses command-line options
      grep—searches a file for a pattern
      groups—prints group membership of user
      gzip, gunzip, zcat—compresses or expands files
      head—outputs the first ten lines of a file(s)
      host—prints information about specified hosts or zones in DNS
      id—prints the username, user ID, group name, and group ID
      jsh—the standard, job control shell
      kill—sends a signal to terminate one or more processes
      killall—kills processes by name
      less—opposite of more
      line—reads one line
      ln—creates hard links to files
      logname—gets the name of the user running the process
      look—displays lines beginning with a given string
      lp—sends output to a printer (AT&T)
      lpr—sends output to a printer (UCB)
      lpstat—prints information about the status of the LP print service (AT&T)
      lpq—prints information about the status of the printer (UCB)
      ls—lists contents of directory
      mail, rmail—reads mail or sends mail to users
      mailx—interactive message processing system
      make—maintains, updates, and regenerates groups of related programs and files
      man—formats and displays the online manual pages
      manpath—determines user's search path for man pages
      mesg—permits or denies messages resulting from the write command
      mkdir—creates a directory
      more—browses or pages through a text file
      mtools—utilities to access DOS disks in UNIX
      mv—moves or renames files
      nawk—pattern scanning and processing language
      newgrp—logs into a new group
      news—prints news items
      nice—runs a command at low priority
      nohup—makes commands immune to hangups and quits
      od—octal dump
      pack, pcat, unpack—compresses and expands files
      passwd—changes the login password and password attributes
      paste—merges same lines of several files or subsequent lines of one file
      pcat—(see pack)
      pine—a Program for Internet News and E-mail
      pg—displays files one page at a time
      pr—prints files
      ping—reports if a remote system is reachable and alive
      ps—reports process status
      pstree—displays a tree of processes
      pwd—displays the present working directory name
      quota—displays users' disk usage and limits
      rcp—remote file copy
      rdate—gets the date and time via the network
      rgrep—a recursive, highlighting grep program
      rlogin—remote login
      rm—removes files from directories
      rmdir—removes a directory
      rsh—starts a remote shell
      ruptime—shows the host status of local machines
      rwho—who is logged in on local machines
      script—creates a typescript of a terminal session
      sed—streamlined editor
      size—prints section sizes in bytes of object files
      sleep—suspends execution for some number of seconds
      sort—sorts and/or merges files
      spell—finds spelling errors
      split—splits a file into pieces
      strings—finds any printable strings in an object or binary file
      stty—sets the options for a terminal
      su—become superuser or another user
      sum—calculates a checksum for a file
      sync—updates the superblock and sends changed blocks to disk
      tabs—sets tab stops on a terminal
      tail—displays the tail end of a file
      talk—allows you to talk to another user
      tar—stores and retrieves files from an archive file, normally a tape device
      tee—replicates the standard output
      telnet—communicates with a remote host
      test—evaluates an expression
      time—displays a summary of time used by this shell and its children
      timex—times a command; reports process data and system activity
      top—displays top CPU processes
      touch—updates access time and/or modification time of a file
      tput—initializes a terminal or queries the terminfo database
      tr—translates characters
      true—provides successful exit status
      tsort—topological sort
      tty—gets the name of the terminal
      umask—sets file-creation mode mask for permissions
      uname—prints name of current machine
      uncompress—restores files to their original state after they have been compressed using the compress command
      uniq—reports on duplicate lines in a file
      units—converts quantities expressed in standard scales to other scales
      unpack—expands files created by pack
      uucp—copies files to another system, UNIX-to-UNIX system copy
      uuencode, uudecode—encodes a binary file into ASCII text in order to send it through e-mail, or converts it back into its original form
      wc—counts lines, words, and characters
      what—extracts SCCS version information from a file by printing information found after the @(#) pattern
      which—locates a command and displays its pathname or alias (UCB)
      whereis—locates the binary, source, and manual page files for a command (UCB)
      who—displays who is logged on the system
      write—writes a message to another user
      xargs—constructs an argument list(s) and executes a command
      zcat—uncompresses a compressed file to standard output; Same as uncompress –c
      zipinfo—lists detailed information about a ZIP archive
      zmore—file perusal filter for crt viewing of compressed text
      Appendix B.  Comparison of the Shells
      Section B.1.  The Shells Compared
      Section B.2.  tcsh versus csh
      Section B.3.  bash versus sh
      CD-ROM Warranty
      About the CD-ROM
   Index
Previous Section  < Day Day Up >  Next Section