Linux Shell Scripting with Bash (Paperback)
暫譯: 使用 Bash 的 Linux Shell 腳本編寫 (平裝本)

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 的起源。檔案與檔案系統。目錄。inode 與連結。管道與套接字檔案。設備檔案。

2. 操作 Shell
- Bash 關鍵字。命令基礎。命令列編輯。變數賦值與顯示訊息。多個命令。命令歷史。目錄命令。專門的導航與歷史。冒號命令。參考部分。

3. 檔案、使用者與 Shell 自訂
- 列出檔案。printf 命令。獲取幫助。修正顯示。處理檔案。與人員合作。Shell 別名。Bash 哈希表。自訂提示符。長命令列。自訂命令列編輯。您的會話配置檔。參考部分。

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

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

6. 表達式
- 擴展。基本 if 命令。檔案表達式。多重測試。字串。算術表達式。邏輯表達式。關係運算。位元運算。自我參考運算。其他 let 特性。temperature.bash:華氏轉攝氏。算術測試。模式識別。通配符選項。檔名大括號擴展({..})。美元符號替代。算術表達式替代(((..)))。mixer.bash:HTML 顏色混合器。參考部分。

7. 複合命令
- 命令狀態碼。if 命令。case 命令。while 迴圈。until 迴圈。for 迴圈。嵌入式 let(((..)))。分組命令({..})。report.bash:報告格式化器。

8. 除錯與版本控制
- Shell 除錯功能。除錯陷阱。版本控制(CVS)。創建記錄。監視運行中的腳本。使用 time 計時執行。創建手冊頁。源代碼補丁。Shell 存檔。參考部分。

9. 參數與子 Shell
- 位置參數。getopts 命令。getopt 命令。子 Shell。參考部分。

10. 工作控制與信號
- 工作控制。信號。suspend 命令。陷阱。退出處理程序。killall 命令。友好處理。進程狀態。參考部分。

11. 文本檔案基礎
- 處理路徑名。檔案截斷。識別檔案。創建與刪除檔案。移動與複製檔案。更多檔案資訊。帳戶間傳輸檔案(wget)。使用 FTP 傳輸檔案。使用安全 FTP(sftp)傳輸檔案。驗證檔案。分割大型檔案。製表符與空格。臨時檔案。鎖定檔案。命名管道。進程替代。打開檔案。使用 head 和 tail。檔案統計。切割。粘貼。列。折疊。合併。參考部分。

12. 文本檔案處理
- 尋找行。定位檔案。尋找檔案。排序。字符編輯(tr)。檔案編輯(sed)。壓縮檔案。參考部分。

13. 控制台腳本
- Linux 控制台。控制台鍵盤。控制台顯示。tput。選擇菜單。自訂菜單。參考部分。

14. 函數與腳本執行
- 執行腳本。Linux 執行環境。source 命令(.)。使用 exec 切換腳本。編寫重複執行的腳本。編寫持續執行的腳本。Shell 函數。局部變數。遞歸與嵌套函數。函數屬性。參考部分。

15. Shell 安全性
- 基本 Linux 安全模型。了解您是誰(id)。轉移擁有權(chown/chgrp)。更改訪問權限(chmod)。預設訪問權限(umask)。setuid/setgid 與腳本。chroot 命令。資源限制(ulimit)。受限 Shell。安全檔案刪除(wipe)。參考部分。

16. 網路程式設計
- 套接字。客戶端-伺服器與對等網路。網路客戶端。CGI 腳本。CGI 環境變數。處理表單。基本網頁剝離(lynx)。參考部分。

17. 數據結構與資料庫
- 使用 Bash 陣列的關聯陣列。使用 Bash 陣列的哈希表。使用 Bash 陣列的二元樹。處理 PostgreSQL 資料庫(psql)。處理 MySQL 資料庫。參考部分。

18. 最後主題
- echo 命令。set 的更多用途。日期轉換。完成。區域設置。du 命令。記憶體使用。noclobber 和強制覆蓋。fc 命令。!字詞指定符與修飾符。從 C 執行腳本。旅程的結束。參考部分。

附錄 A. 完整範例

附錄 B. Bash 內建命令摘要

附錄 C. Bash 選項

附錄 D. 錯誤代碼

附錄 E. 信號

附錄 F. ASCII 表

詞彙表

索引