Wicked Cool Shell Scripts

Book description

Fun and functional Linux, Mac OS X and UNIX shell scripts

The UNIX shell is the main scripting environment of every Linux, Mac OS X and UNIX system, whether a rescued laptop or a million-dollar mainframe. This cookbook of useful, customizable, and fun scripts gives you the tools to solve common Linux, Mac OS X and UNIX problems and personalize your computing environment. Among the more than 100 scripts included are an interactive calculator, a spell checker, a disk backup utility, a weather tracker, and a web logfile analysis tool. The book also teaches you how to write your own sophisticated shell scripts by explaining the syntax and techniques used to build each example scripts. Examples are written in Bourne Shell (sh) syntax.

Table of contents

  1. Copyright
  2. Introduction
    1. This Book Is for You If . . .
    2. What Is a Shell Script, Anyway?
    3. Which Shell?
    4. Organization of This Book
    5. The Website
    6. Acknowledgments
    7. Finally . . .
  3. THE MISSING CODE LIBRARY
    1. What Is POSIX?
    2. #1 Finding Programs in the PATH
    3. #2 Validating Input: Alphanumeric Only
    4. #3 Normalizing Date Formats
    5. #4 Presenting Large Numbers Attractively
    6. #5 Validating Integer Input
    7. #6 Validating Floating-Point Input
    8. #7 Validating Date Formats
    9. #8 Sidestepping Poor Echo Implementations
    10. #9 An Arbitrary-Precision Floating-Point Calculator
    11. #10 Locking Files
    12. #11 ANSI Color Sequences
    13. #12 Building a Shell Script Library
    14. #13 Debugging Shell Scripts
  4. IMPROVING ON USER COMMANDS
    1. #14 Formatting Long Lines
    2. #15 Archiving Files As They're Removed
    3. #16 Working with the Removed File Archive
    4. #17 Logging File Removals
    5. #18 Displaying the Contents of Directories
    6. #19 Locating Files by Filename
    7. #20 Emulating Another Environment: DIR
    8. #21 Digging Around in the Man Page Database
    9. #22 Displaying the Time in Different Time Zones
  5. CREATING UTILITIES
    1. #23 A Reminder Utility
    2. #24 An Interactive Calculator
    3. #25 Checking the Spelling of Individual Words
    4. #26 Shpell: An Interactive Spell-Checking Facility
    5. #27 Adding a Local Dictionary to Spell
    6. #28 Converting Temperatures
    7. #29 Calculating Loan Payments
    8. #30 Keeping Track of Events
  6. TWEAKING UNIX
    1. #31 Displaying a File with Line Numbers
    2. #32 Displaying a File with Additional Information
    3. #33 Wrapping Only Long Lines
    4. #34 Emulating GNU-Style Flags with Quota
    5. #35 Making sftp Look More Like ftp
    6. #36 Fixing grep
    7. #37 Working with Compressed Files
    8. #38 Ensuring Maximally Compressed Files
  7. SYSTEM ADMINISTRATION: MANAGING USERS
    1. #39 Analyzing Disk Usage
    2. #40 Reporting Disk Hogs
    3. #41 Figuring Out Available Disk Space
    4. #42 Improving the Readability of df Output
    5. #43 Implementing a Secure Locate
    6. #44 Adding Users to the System
    7. #45 Suspending a User Account
    8. #46 Deleting a User Account
    9. #47 Validating the User Environment
    10. #48 Cleaning Up After Guests Leave
  8. SYSTEM ADMINISTRATION: SYSTEM MAINTENANCE
    1. #49 Tracking Set User ID Applications
    2. #50 Setting the System Date
    3. #51 Displaying Which Services Are Enabled
    4. #52 Killing Processes by Name
    5. #53 Validating User crontab Entries
    6. #54 Ensuring That System cron Jobs Are Run
    7. #55 Rotating Log Files
    8. #56 Managing Backups
    9. #57 Backing Up Directories
  9. WEB AND INTERNET USERS
    1. #58 Calculating Time Spent Online
    2. #59 Downloading Files via FTP
    3. #60 Tracking BBC News with lynx
    4. #61 Extracting URLs from a Web Page
    5. #62 Defining Words Online
    6. #63 Keeping Track of the Weather
    7. #64 Checking for Overdue Books at the Library
    8. #65 Digging Up Movie Info from IMDb
    9. #66 Calculating Currency Values
    10. #67 Tracking Your Stock Portfolio
    11. #68 Tracking Changes on Web Pages
  10. WEBMASTER HACKS
    1. Running the Scripts in This Chapter
    2. #69 Seeing the CGI Environment
    3. #70 Logging Web Events
    4. #71 Building Web Pages on the Fly
    5. #72 Processing Contact Forms
    6. #73 Creating a Web-Based Photo Album
    7. #74 Building a Guest Book
    8. #75 Creating a Text-Based Web Page Counter
    9. #76 Displaying Random Text
  11. WEB AND INTERNET ADMINISTRATION
    1. #77 Identifying Broken Internal Links
    2. #78 Reporting Broken External Links
    3. #79 Verifying Spelling on Web Pages
    4. #80 Managing Apache Passwords
    5. #81 Synchronizing Directories with FTP
    6. #82 Synchronizing to a Remote Directory via FTP
    7. #83 Synchronizing Files with SFTP
  12. INTERNET SERVER ADMINISTRATION
    1. #84 Exploring the Apache access_log
    2. #85 Understanding Search Engine Traffic
    3. #86 Exploring the Apache error_log
    4. #87 Avoiding Disaster with a Remote Archive
    5. #88 Mirroring a Website
    6. #89 Tracking FTP Usage
    7. #90 Monitoring Network Status
    8. #91 Renicing Tasks by Process Name
    9. #92 Adding New Virtual Host Accounts
  13. MAC OS X SCRIPTS
    1. #93 List NetInfo Users
    2. #94 Adding a User to a Mac OS X System
    3. #95 Adding an Email Alias
    4. #96 Set the Terminal Title Dynamically
    5. #97 Producing Summary Listings of iTunes Libraries
    6. #98 Fixing the Open Command
  14. SHELL SCRIPT FUN AND GAMES
    1. #99 Unscramble: A Word Game
    2. #100 Guess the Word Before It's Too Late: Hangman
    3. #101 A State Capitals Quiz
  15. Afterword
  16. Index

Product information

  • Title: Wicked Cool Shell Scripts
  • Author(s): Dave Taylor
  • Release date: January 2004
  • Publisher(s): No Starch Press
  • ISBN: 9781593270124