Classic Shell Scripting (Paperback)
暫譯: 經典殼層腳本編寫 (平裝本)

Arnold Robbins, Nelson H.F. Beebe

買這商品的人也買了...

相關主題

商品描述

Description:

Shell scripting skills never go out of style. It's the shell that unlocks the real potential of Unix. Shell scripting is essential for Unix users and system administrators-a way to quickly harness and customize the full power of any Unix system. With shell scripts, you can combine the fundamental Unix text and file processing commands to crunch data and automate repetitive tasks. But beneath this simple promise lies a treacherous ocean of variations in Unix commands and standards. Classic Shell Scripting is written to help you reliably navigate these tricky waters.

Writing shell scripts requires more than just a knowledge of the shell language, it also requires familiarity with the individual Unix programs: why each one is there, how to use them by themselves, and in combination with the other programs. The authors are intimately familiar with the tips and tricks that can be used to create excellent scripts, as well as the traps that can make your best effort a bad shell script. With Classic Shell Scripting you'll avoid hours of wasted effort. You'll learn not only write useful shell scripts, but how to do it properly and portably.

The ability to program and customize the shell quickly, reliably, and portably to get the best out of any individual system is an important skill for anyone operating and maintaining Unix or Linux systems. Classic Shell Scripting gives you everything you need to master these essential skills.

 

Table of Contents:

Foreword

Preface

1. Background

      1.1 Unix History

      1.2 Software Tools Principles

      1.3 Summary

2. Getting Started

      2.1 Scripting Languages Versus Compiled Languages

      2.2 Why Use a Shell Script?

      2.3 A Simple Script

      2.4 Self-Contained Scripts: The #! First Line

      2.5 Basic Shell Constructs

      2.6 Accessing Shell Script Arguments

      2.7 Simple Execution Tracing

      2.8 Internationalization and Localization

      2.9 Summary

3. Searching and Substitutions

      3.1 Searching for Text

      3.2 Regular Expressions

      3.3 Working with Fields

      3.4 Summary

4. Text Processing Tools

      4.1 Sorting Text

      4.2 Removing Duplicates

      4.3 Reformatting Paragraphs

      4.4 Counting Lines, Words, and Characters

      4.5 Printing

      4.6 Extracting the First and Last Lines

      4.7 Summary

5. Pipelines Can Do Amazing Things

      5.1 Extracting Data from Structured Text Files

      5.2 Structured Data for the Web

      5.3 Cheating at Word Puzzles

      5.4 Word Lists

      5.5 Tag Lists

      5.6 Summary

6. Variables, Making Decisions, and Repeating Actions

      6.1 Variables and Arithmetic

      6.2 Exit Statuses

      6.3 The case Statement

      6.4 Looping

      6.5 Functions

      6.6 Summary

7. Input and Output, Files, and Command Evaluation

      7.1 Standard Input, Output, and Error

      7.2 Reading Lines with read

      7.3 More About Redirections

      7.4 The Full Story on printf

      7.5 Tilde Expansion and Wildcards

      7.6 Command Substitution

      7.7 Quoting

      7.8 Evaluation Order and eval

      7.9 Built-in Commands

      7.10 Summary

8. Production Scripts

      8.1 Path Searching

      8.2 Automating Software Builds

      8.3 Summary

9. Enough awk to Be Dangerous

      9.1 The awk Command Line

      9.2 The awk Programming Model

      9.3 Program Elements

      9.4 Records and Fields

      9.5 Patterns and Actions

      9.6 One-Line Programs in awk

      9.7 Statements

      9.8 User-Defined Functions

      9.9 String Functions

      9.10 Numeric Functions

      9.11 Summary

10. Working with Files

      10.1 Listing Files

      10.2 Updating Modification Times with touch

      10.3 Creating and Using Temporary Files

      10.4 Finding Files

      10.5 Running Commands: xargs

      10.6 Filesystem Space Information

      10.7 Comparing Files

      10.8 Summary

11. Extended Example: Merging User Databases

      11.1 The Problem

      11.2 The Password Files

      11.3 Merging Password Files

      11.4 Changing File Ownership

      11.5 Other Real-World Issues

      11.6 Summary

12. Spellchecking

      12.1 The spell Program

      12.2 The Original Unix Spellchecking Prototype

      12.3 Improving ispell and aspell

      12.4 A Spellchecker in awk

      12.5 Summary

13. Processes

      13.1 Process Creation

      13.2 Process Listing

      13.3 Process Control and Deletion

      13.4 Process System-Call Tracing

      13.5 Process Accounting

      13.6 Delayed Scheduling of Processes

      13.7 The /proc Filesystem

      13.8 Summary

14. Shell Portability Issues and Extensions

      14.1 Gotchas

      14.2 The bash shopt Command

      14.3 Common Extensions

      14.4 Download Information

      14.5 Other Extended Bourne-Style Shells

      14.6 Shell Versions

      14.7 Shell Initialization and Termination

      14.8 Summary

15. Secure Shell Scripts: Getting Started

      15.1 Tips for Secure Shell Scripts

      15.2 Restricted Shell

      15.3 Trojan Horses

      15.4 Setuid Shell Scripts: A Bad Idea

      15.5 ksh93 and Privileged Mode

      15.6 Summary

A. Writing Manual Pages

B. Files and Filesystems

C. Important Unix Commands

Bibliography

Glossary

Index

商品描述(中文翻譯)

**描述:**

Shell 腳本技能永遠不會過時。正是這個 shell 解鎖了 Unix 的真正潛力。Shell 腳本對於 Unix 使用者和系統管理員來說是必不可少的,它是一種快速利用和自定義任何 Unix 系統全部功能的方法。透過 shell 腳本,您可以結合基本的 Unix 文本和文件處理命令來處理數據並自動化重複的任務。但在這個簡單的承諾之下,潛藏著一片危險的海洋,充滿了 Unix 命令和標準的變化。《經典 Shell 腳本》旨在幫助您可靠地導航這些棘手的水域。

撰寫 shell 腳本不僅需要了解 shell 語言,還需要熟悉各個 Unix 程式:每個程式的存在原因、如何單獨使用它們,以及如何與其他程式結合使用。作者對於創建優秀腳本的技巧和竅門非常熟悉,也了解可能使您最佳努力變成糟糕 shell 腳本的陷阱。透過《經典 Shell 腳本》,您將避免浪費數小時的努力。您將學會不僅是撰寫有用的 shell 腳本,還有如何正確且可攜帶地做到這一點。

快速、可靠且可攜帶地編程和自定義 shell,以充分發揮任何單一系統的最佳性能,對於任何操作和維護 Unix 或 Linux 系統的人來說都是一項重要技能。《經典 Shell 腳本》提供了掌握這些基本技能所需的一切。

**目錄:**

**前言**

**序言**

**1. 背景**
      1.1 Unix 歷史
      1.2 軟體工具原則
      1.3 總結

**2. 開始使用**
      2.1 腳本語言與編譯語言
      2.2 為什麼使用 shell 腳本?
      2.3 一個簡單的腳本
      2.4 自包含腳本:#! 第一行
      2.5 基本 shell 結構
      2.6 訪問 shell 腳本參數
      2.7 簡單執行追蹤
      2.8 國際化與本地化
      2.9 總結

**3. 搜尋與替換**
      3.1 搜尋文本
      3.2 正規表達式
      3.3 處理欄位
      3.4 總結

**4. 文本處理工具**
      4.1 排序文本
      4.2 刪除重複項
      4.3 重新格式化段落
      4.4 計算行數、單詞數和字符數
      4.5 列印
      4.6 提取第一行和最後一行
      4.7 總結

**5. 管道可以做驚人的事情**
      5.1 從結構化文本文件中提取數據
      5.2 用於網路的結構化數據
      5.3 在字謎中作弊
      5.4 單詞列表
      5.5 標籤列表
      5.6 總結

**6. 變數、做決策和重複行動**
      6.1 變數與算術
      6.2 退出狀態
      6.3 case 語句
      6.4 循環
      6.5 函數
      6.6 總結

**7. 輸入與輸出、文件與命令評估**
      7.1 標準輸入、輸出與錯誤
      7.2 使用 read 讀取行
      7.3 更多關於重定向
      7.4 printf 的完整故事
      7.5 波浪號擴展與通配符
      7.6 命令替換
      7.7 引號
      7.8 評估順序與 eval
      7.9 內建命令
      7.10 總結

**8. 生產腳本**
      8.1 路徑搜尋
      8.2 自動化軟體建置
      8.3 總結

**9. 足夠的 awk 以致危險**
      9.1 awk 命令行
      9.2 awk 程式模型
      9.3 程式元素
      9.4 記錄與欄位
      9.5 模式與行動
      9.6 awk 中的一行程式
      9.7 語句
      9.8 使用者定義函數
      9.9 字串函數
      9.10 數值函數
      9.11 總結

**10. 處理文件**
      10.1 列出文件
      10.2 使用 touch 更新修改時間
      10.3 創建和使用臨時文件
      10.4 查找文件
      10.5 執行命令:xargs
      10.6 檔案系統空間資訊
      10.7 比較文件
      10.8 總結

**11. 擴展範例:合併使用者數據庫**
      11.1 問題
      11.2 密碼文件
      11.3 合併密碼文件
      11.4 更改文件擁有權
      11.5 其他現實世界問題
      11.6 總結

**12. 拼寫檢查**
      12.1 spell 程式
      12.2 原始 Unix 拼寫檢查原型
      12.3 改進 ispell 和 aspell
      12.4 在 awk 中的拼寫檢查器
      12.5 總結

**13. 進程**
      13.1 進程創建
      13.2 進程列表
      13.3 進程控制與刪除
      13.4 進程系統調用追蹤
      13.5 進程會計
      13.6 進程的延遲排程
      13.7 /proc 檔案系統
      13.8 總結

**14. Shell 可攜性問題與擴展**
      14.1 注意事項
      14.2 bash shopt 命令
      14.3 常見擴展
      14.4 下載資訊
      14.5 其他擴展的 Bourne 風格 shell
      14.6 Shell 版本
      14.7 Shell 初始化與終止
      14.8 總結

**15. 安全的 Shell 腳本:入門**
      15.1 安全 Shell 腳本的提示
      15.2 限制 Shell
      15.3 特洛伊木馬
      15.4 Setuid Shell 腳本:一個壞主意
      15.5 ksh93 和特權模式
      15.6 總結

**A. 撰寫手冊頁**

**B. 文件與檔案系統**

**C. 重要的 Unix 命令**

**參考文獻**

**詞彙表**

**索引**