Linux Shell Scripting with Bash (Paperback)

Ken O. Burtch

  • 出版商: SAMS
  • 出版日期: 2004-02-08
  • 售價: $1,650
  • 貴賓價: 9.5$1,568
  • 語言: 英文
  • 頁數: 432
  • 裝訂: Paperback
  • ISBN: 0672326426
  • ISBN-13: 9780672326424
  • 相關分類: Command LineLinux
  • 立即出貨 (庫存=1)

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

商品描述

 

With the proliferation of Linux as both a server and desktop operating system, users are looking for more advanced methods of getting up and running quickly and efficiently solving problems. The most powerful way of achieving this is to employ the command line interface known as the shell. Bash, the Bourne Again Shell, is the most popular Linux shell today.

Linux Shell Scripting with Bash emphasizes professional scripting solutions through the use of structured programming and standard Linux development tools. The book focuses on the Linux environment and the robust tool set therein. Because the shell relies on the operating system for its functionality this is the ideal methodology to learn shell scripting and sets the book apart from general scripting titles. Promoting good programming practices with real-world scripts, which are readable, extendable, and easy to debug, this book will be an essential asset to any Linux user.

Table of Contents

1. The Linux Environment.

The Origin of Linux. Files and File Systems. Directories. Inodes and Links. Pipe and Socket Files. Device Files.

2. Operating the Shell.

Bash Keywords. Command Basics. Command-Line Editing. Variable Assignments and Displaying Messages. Multiple Commands. Command History. Directory Commands. Specialized Navigation and History. The Colon Command. Reference Section.

3. Files, Users, and Shell Customization.

Listing Files. printf Command. Getting Help. Fixing the Display. Working with Files. Working with People. Shell Aliases. The Bash Hash Table. Customizing Your Prompt. Long Command Lines. Customizing Command-Line Editing. Your Session Profile. Reference Section.

4. Script Basics.

Creating a Script. Creating a Well-Behaved Script. The Header. Global Declarations. Sanity Checks. The Main Script. Cleanup. Stopping a Script. Reading Keyboard Input. Basic Redirection. Standard Output, Error, and Input. Built-In Versus Linux Commands. The Set and Shopt Commands. Reference Section.

5. Variables.

Variable Basics. Predefined Variables. The Effect of Quotations. Variable Attributes. Arrays. Exporting Variables and the Linux Environment. The eval Command. story.bash: A Story Generator. Reference Section.

6. Expressions.

Expansions. The Basic if Command. File Expressions. Multiple Tests. Strings. Arithmetic Expressions. Logical Expressions. Relational Operations. Bitwise Operations. Self-Referential Operations. Other let Features. temperature.bash: Converting Fahrenheit to Celsius. Arithmetic Tests. Pattern Recognition. Globbing Options. Filename Brace Expansion ( {..} ). Dollar Sign Substitutions. Arithmetic Expression Substitution ( ((..)) ). mixer.bash: HTML Color Mixer. Reference Section.

7. Compound Commands.

Command Status Codes. if Command. case Command. while Loop. until Loop. for Loops. Embedded let ( ((..)) ). Grouping Commands ( {..} ). report.bash: Report Formatter.

8. Debugging and Version Control.

Shell Debugging Features. Debug Traps. Version Control (CVS). Creating Transcripts. Watching Running Scripts. Timing Execution with Time. Creating Man Pages. Source Code Patches. Shell Archives. Reference Section.

9. Parameters and Subshells.

Positional Parameters. The getopts Command. The getopt Command. Subshells. Reference Section.

10. Job Control and Signals.

Job Control. Signals. The suspend Command. Traps. Exit Handlers. The killall Command. Being Nice. Process Status. Reference Section.

11. Text File Basics.

Working with Pathnames. File Truncation. Identifying Files. Creating and Deleting Files. Moving and Copying Files. More Information about Files. Transferring Files between Accounts (wget). Transferring Files with FTP. Transferring Files with Secure FTP (sftp). Verifying Files. Splitting Large Files. Tabs and Spaces. Temporary Files. Lock Files. Named Pipes. Process Substitution. Opening Files. Using head and tail. File Statistics. Cutting. Pasting. Columns. Folding. Joining. Merging. Reference Section.

12. Text File Processing.

Finding Lines. Locating Files. Finding Files. Sorting. Character Editing (tr). File Editing (sed). Compressing Files. Reference Section.

13. Console Scripting.

The Linux Console. The Console Keyboard. The Console Display. tput. select Menus. Custom Menus. Reference Section.

14. Functions and Script Execution.

Running Scripts. The Linux Execution Environment. The Source Command (.). Switching Scripts with exec. Writing Recurring Scripts. Writing Continually Executing Scripts. Shell Functions. Local Variables. Recursion and Nested Functions. Function Attributes. Reference Section.

15. Shell Security.

The Basic Linux Security Model. Knowing Who You Are (id). Transferring Ownership (chown/chgrp). Changing Access Rights (chmod). Default Access Rights (umask). setuid/setgid and Scripts. The chroot Command. Resource Limits (ulimit). Restricted Shells. Secure File Deletion (wipe). Reference Section.

16. Network Programming.

Sockets. Client-Server and Peer-to-Peer. Network Clients. CGI Scripting. CGI Environment Variables. Processing Forms. Basic Web Page Stripping (lynx). Reference Section.

17. Data Structures and Databases.

Associative Arrays Using Bash Arrays. Hash Tables Using Bash Arrays. Binary Trees Using Bash Arrays. Working with PostgreSQL Databases (psql). Working with MySQL Databases. Reference Section.

18. Final Topics.

The echo Command. More Uses for set. Date Conversions. Completions. Locales. The du Command. Memory Usage. noclobber and Forced Overwriting. The fc Command. ! Word Designators and Modifiers. Running Scripts from C. Journey's End. Reference Section.

Appendix A. A Complete Example.

Appendix B. Summary of Bash Built-In Commands.

Appendix C. Bash Options.

Appendix D. Error Codes.

Appendix E. Signals.

Appendix F. ASCII Table.

Glossary.

Index.

商品描述(中文翻譯)

隨著Linux作為伺服器和桌面操作系統的普及,使用者正在尋找更高級的方法來快速且有效地解決問題。實現這一目標的最強大方式是使用稱為shell的命令行界面。Bash,即Bourne Again Shell,是當今最流行的Linux shell。

《Linux Shell Scripting with Bash》通過使用結構化編程和標準Linux開發工具,強調專業的腳本解決方案。該書專注於Linux環境和其中強大的工具集。由於shell依賴於操作系統的功能,這是學習shell腳本的理想方法,並使該書與一般的腳本書籍有所區別。通過提倡具有可讀性、可擴展性和易於調試的真實腳本,這本書將成為任何Linux使用者的重要資產。

目錄:

1. Linux環境
- Linux的起源
- 文件和文件系統
- 目錄
- Inodes和鏈接
- 管道和套接字文件
- 設備文件

2. 操作shell
- Bash關鍵字
- 命令基礎
- 命令行編輯
- 變量賦值和顯示消息
- 多個命令
- 命令歷史
- 目錄命令
- 專業導航和歷史
- 冒號命令
- 參考部分

3. 文件、使用者和shell自定義
- 列出文件
- printf命令
- 獲取幫助
- 修復顯示
- 與文件一起工作
- 與人一起工作
- shell別名
- Bash哈希表
- 自定義提示符
- 長命令行
- 自定義命令行編輯
- 會話配置文件
- 參考部分

4. 腳本基礎
- 創建腳本
- 創建良好行為的腳本
- 標頭
- 全局聲明
- 健全性檢查
- 主腳本
- 清理
- 停止腳本
- 讀取鍵盤輸入
- 基本重定向
- 標準輸出、錯誤和輸入
- 內置命令與Linux命令
- Set和Shopt命令
- 參考部分

5. 變量
- 變量基礎
- 預定義變量
- 引號的影響
- 變量屬性
- 數組
- 導出變量和Linux環境
- eval命令
- story.bash:故事生成器
- 參考部分

6. 表達式
- 擴展
- 基本if命令
- 文件表達式
- 多個測試
- 字符串
- 算術表達式
- 邏輯表達式
- 關係操作
- 位操作
- 自引用操作
- 其他let功能
- temperature.bash:華氏轉攝氏
- 算術測試
- 模式識別
- Globbing選項
- 文件名大括號展開({..})
- 美元符號替換
- 算術表達式替換(((..)))
- mixer.bash:HTML顏色混合器
- 參考部分

7. 複合命令
- 命令狀態碼
- if命令
- case命令
- while循環
- until循環
- for循環
- 嵌套let(((..)))
- 命令分組({..})
- report.bash:報告格式化程序

8. 調試和版本控制
- Shell調試功能
- 調試陷阱
- 版本控制(CVS)
- 創建轉錄
- 監視運行中的腳本
- 使用時間計時執行
- 創建手冊頁面
- 源代碼補丁
- Shell存檔
- 參考部分

9. 參數和子shell