O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

UNIX® Shells by Example, Third Edition

Book Description

Five UNIX shells, three essential utilities, one indispensable resource!

  • Learn UNIX shell programming the easy way, using hands-on examples

  • Covers all five leading UNIX shells-C, Bourne, Korn, bash, and tcsh

  • By best-selling author Ellie Quigley, Silicon Valley's top UNIX instructor

  • The best-selling UNIX Shells by Example continues to be the only book you need to learn UNIX shell programming. UNIX Shells by Example, Third Edition adds thorough coverage of the new bash and tcsh shells to the full explanations in Quigley's famous treatment of the C, Bourne, and Korn shells and the awk, sed, and grep utilities, making this the most complete UNIX shell programming book available anywhere. Using proven techniques drawn from her acclaimed Silicon Valley UNIX classes, Quigley transforms you into an expert-level shell programmer. You'll learn what the shells are, what they do, and how to program them, as well as how and when to use awk, sed, and grep. Code examples, completely revised and classroom-tested for this edition, explain concepts first-hand and can serve as the basis for your own projects.

  • Explains the C, Bourne, Korn, bash, and tcsh shells in one cohesive way-you'll understand which shell to use and why

  • Details the essential awk, sed, and grep programming utilities

  • Offers proven teaching methods from a top UNIX shell instructor

  • Provides source code and data files for all examples on the CD-ROM, so you can experiment with them on your own system

  • UNIX system administrators, application developers, and power users will turn to this book again and again, both as a vital classroom learning tool and as a favorite reference manual.

    About the CD-ROM

    Provides source code and data files for all examples in the book!

    Table of Contents

    1. Copyright
    2. Preface
    3. Introduction to UNIX Shells
      1. Definition and Function
      2. System Startup and the Login Shell
      3. Processes and the Shell
      4. The Environment and Inheritance
      5. Executing Commands from Scripts
    4. The UNIX Toolbox
      1. Regular Expressions
      2. Combining Regular Expression Metacharacters
    5. The grep Family
      1. The grep Command
      2. grep Examples with Regular Expressions
      3. grep with Pipes
      4. grep with Options
      5. egrep (Extended grep)
      6. Fixed grep or Fast grep
    6. sed, the Streamlined Editor
      1. What Is sed?
      2. How Does sed Work?
      3. Addressing
      4. Commands and Options
      5. Error Messages and Exit Status
      6. sed Examples
      7. sed Scripting
    7. The awk Utility: awk as a UNIX Tool
      1. What Is awk?
      2. awk's Format
      3. Formatting Output
      4. awk Commands from Within a File
      5. Records and Fields
      6. Patterns and Actions
      7. Regular Expressions
      8. awk Commands in a Script File
      9. Review
    8. The awk Utility: awk Programming Constructs
      1. Comparison Expressions
      2. Review
    9. The awk Utility: awk Programming
      1. Variables
      2. Redirection and Pipes
      3. Pipes
      4. Closing Files and Pipes
      5. Review
      7. Conditional Statements
      8. Loops
      9. Program Control Statements
      10. Arrays
      11. awk Built-In Functions
      12. Built-In Arithmetic Functions
      13. User-Defined Functions (nawk)
      14. Review
      16. Odds and Ends
      17. Review
    10. The Interactive Bourne Shell
      1. Startup
      2. Programming with the Bourne Shell
    11. The C Shell
      1. The Interactive C Shell
      2. Programming with the C Shell
    12. The Korn Shell
      1. Interactive Korn Shell
      2. Programming with the Korn Shell
    13. The Interactive bash Shell
      1. Introduction
      2. Command Line Shortcuts
      3. Variables
    14. Programming with the bash Shell
      1. Introduction
      2. Reading User Input
      3. Arithmetic
      4. Positional Parameters and Command Line Arguments
      5. Conditional Constructs and Flow Control
      6. Looping Commands
      7. Functions
      8. Trapping Signals
      9. Debugging
      10. Processing Command Line Options with getopts
      11. The eval Command and Parsing the Command Line
      12. bash Options
      13. Shell Built-In Commands
    15. The Interactive TC Shell
      1. Introduction
      2. The TC Shell Environment
      3. Command Line Shortcuts
      4. Job Control
      5. Metacharacters
      6. Redirection and Pipes
      7. Variables
      8. Arrays
      9. Special Variables and Modifiers
      10. Command Substitution
      11. Quoting
      12. Built-In Commands
    16. Useful UNIX Utilities for Shell Programmers
      1. at—at, batch—execute commands at a later time
      2. awk—pattern scanning and processing language
      3. banner—make posters
      4. basename—with a directory name delivers portions of the pathname
      5. bc—processes precision arithmetic
      6. bdiff—compares two big files
      7. cal—displays a calendar
      8. cat—concatenates and displays files
      9. chmod—change the permissions mode of a file
      10. chown—changes owner of file
      11. clear—clears the terminal screen
      12. cmp—compares two files
      13. compress—compress, uncompress, zcat compress, uncompress files, or display expanded files
      14. cp—copies files
      15. cpio—copy file archives in and out
      16. cron—the clock daemon
      17. crypt—encodes or decodes a file
      18. cut—removes selected fields or characters from each line of a file
      19. date—displays the date and time or sets the date
      20. diff—compares two files for differences diff [–bitw] [–c | –Cn
      21. du—summarizes disk usage
      22. echo—echoes arguments
      23. egrep—searches a file for a pattern using full regular expressions
      24. expr—evaluates arguments as an expression
      25. fgrep—search a file for a character string
      26. file—determines the type of a file by looking at its contents
      27. find—finds files
      28. finger—displays information about local and remote users
      29. fmt—simple text formatters
      30. fold—folds long lines
      31. ftp—file transfer program
      32. getopt(s)—parses command line options
      33. grep—searches a file for a pattern
      34. groups—prints group membership of user
      35. id—prints the username, user ID, group name and group ID
      36. jsh—the standard, job control shell
      37. line—reads one line
      38. logname—gets the name of the user running the process
      39. lp—sends output to a printer (AT&T)
      40. lpr—sends output to a printer (UCB)
      41. lpstat—print information about the status of the LP print service (AT&T)
      42. lpq—print information about the status of the printer (UCB)
      43. ls—lists contents of directory
      44. mail—mail, rmail—read mail or send mail to users
      45. mailx—interactive message processing system
      46. make—maintains, updates, and regenerates groups of related programs and files
      47. mesg—permits or denies messages resulting from the write command
      48. mkdir—creates a directory
      49. more—browse or page through a text file
      50. mv—move or rename files
      51. nawk—pattern scanning and processing language
      52. newgrp—log in to a new group
      53. news—prints news items
      54. nice—runs a command at low priority
      55. nohup—makes commands immune to hangups and quits
      56. od—octal dump
      57. pack—pack, pcat, unpack—compresses and expands files
      58. passwd—changes the login password and password attributes
      59. paste—merges same lines of several files or subsequent lines of one file
      60. pcat—(see pack)
      61. pg—displays files a page at a time
      62. pr—prints files
      63. ps—reports process status
      64. pwd—displays the present working directory name
      65. rcp—remote file copy
      66. rlogin—remote login
      67. rm—removes files from directories
      68. rmdir—removes a directory
      69. rsh—starts a remote shell
      70. ruptime—shows the host status of local machines
      71. rwho—who is logged in on local machines
      72. script—creates a typescript of a terminal session
      73. sed—streamlined editor
      74. size—prints section sizes in bytes of object files
      75. sleep—suspends execution for some number of seconds
      76. sort—sort and/or merge files
      77. spell—finds spelling errors
      78. split—splits a file into pieces
      79. strings—finds any printable strings in an object or binary file
      80. stty—sets the options for a terminal
      81. su—become superuser or another user
      82. sum—calculates a checksum for a file
      83. sync—updates the superblock and sends changed blocks to disk
      84. tabs—set tab stops on a terminal
      85. tail—displays the tail end of a file.
      86. talk—allows you to talk to another user
      87. tar—stores and retrieves files from an archive file, normally a tape device
      88. tee—replicates the standard output
      89. telnet—communicates with a remote host
      90. test—evaluates an expression
      91. time—displays a summary of time used by this shell and its children
      92. timex—times a command; reports process data and system activity
      93. touch—updates access time and/or modification time of a file
      94. tput—initializes a terminal or queries the terminfo database
      95. tr—translates characters
      96. true—provide successful exit status
      97. tsort —topological sort
      98. tty—gets the name of the terminal
      99. umask—sets file-creation mode mask for permissions
      100. uname—prints name of current machine
      101. uncompress—restores files to their original state after they have been compressed using the compress command
      102. uniq—reports on duplicate lines in a file
      103. units—converts quantities expressed in standard scales to other scales
      104. unpack—expands files created by pack
      105. uucp—copy files to another system, UNIX-to-UNIX system copy
      106. uuencode—uuencode, uudecode—encode a binary file into ASCII text in order to send it through e-mail, or convert it back into its original form
      107. wc—counts lines, words, and characters
      108. what—extracts SCCS version information from a file by printing information found after the @(#) pattern
      109. which—locates a command and displays its pathname or alias (UCB)
      110. whereis—locates the binary, source, and manual page files for a command (UCB)
      111. who—displays who is logged on the system
      112. write—writes a message to another user
      113. xargs—constructs an argument list(s) and executes a command
      114. zcat—uncompress a compressed file to standard output. Same as uncompress –c
    17. Comparison of the Shells
      1. The Shells Compared
      2. tcsh versus csh
      3. bash versus sh
    18. Steps for Using Quoting Correctly
      1. Backslash
      2. Single Quotes
      3. Double Quotes
      4. Combining Quotes
      5. Setting the Shell Variable