Classic Shell Scripting : Hidden Commands That Unlock the Power of Unix 🔍
Arnold Robbins and Nelson H. F. Beebe O'Reilly Media, Incorporated, 1st, First Edition, PS, 2005
英语 [en] · PDF · 7.7MB · 2005 · 📘 非小说类图书 · 🚀/lgli/lgrs/nexusstc/upload/zlib · Save
描述
Table of Contents 5
Foreword 11
Preface 13
Intended Audience 14
What You Should Already Know 16
Chapter Summary 16
Conventions Used in This Book 19
Code Examples 21
Unix Tools for Windows Systems 21
Cygwin 21
DJGPP 22
MKS Toolkit 22
AT&T UWIN 22
Safari Enabled 23
We’d Like to Hear from You 23
Acknowledgments 24
Chapter 1. Background 25
1.1 Unix History 25
1.2 Software Tools Principles 28
1.3 Summary 30
Chapter 2. Getting Started 32
2.1 Scripting Languages Versus Compiled Languages 32
2.2 Why Use a Shell Script? 33
2.3 A Simple Script 33
2.4 Self-Contained Scripts: The #! First Line 34
2.5 Basic Shell Constructs 36
2.5.1 Commands and Arguments 36
2.5.2 Variables 38
2.5.3 Simple Output with echo 39
2.5.4 Fancier Output with printf 41
2.5.5 Basic I/O Redirection 42
2.5.5.1 Redirection and pipelines 43
2.5.5.2 Special files: /dev/null and /dev/tty 45
2.5.6 Basic Command Searching 46
2.6 Accessing Shell Script Arguments 47
2.7 Simple Execution Tracing 48
2.8 Internationalization and Localization 49
2.9 Summary 52
Chapter 3. Searching and Substitutions 54
3.1 Searching for Text 54
3.1.1 Simple grep 55
3.2 Regular Expressions 55
3.2.1 What Is a Regular Expression? 57
3.2.1.1 POSIX bracket expressions 59
3.2.2 Basic Regular Expressions 61
3.2.2.1 Matching single characters 61
3.2.2.2 Backreferences 63
3.2.2.3 Matching multiple characters with one expression 64
3.2.2.4 Anchoring text matches 65
3.2.2.5 BRE operator precedence 66
3.2.3 Extended Regular Expressions 66
3.2.3.1 Matching single characters 66
3.2.3.2 Backreferences don’t exist 66
3.2.3.3 Matching multiple regular expressions with one expression 67
3.2.3.4 Alternation 67
3.2.3.5 Grouping 68
3.2.3.6 Anchoring text matches 69
3.2.3.7 ERE operator precedence 69
3.2.4 Regular Expression Extensions 69
3.2.5 Which Programs Use Which Regular Expressions? 70
3.2.6 Making Substitutions in Text Files 72
3.2.7 Basic Usage 72
3.2.7.1 Substitution details 74
3.2.8 sed Operation 76
3.2.8.1 To print or not to print 76
3.2.9 Matching Specific Lines 77
3.2.10 How Much Text Gets Changed? 79
3.2.11 Lines Versus Strings 80
3.3 Working with Fields 80
3.3.1 Text File Conventions 81
3.3.2 Selecting Fields with cut 82
3.3.3 Joining Fields with join 84
3.3.4 Rearranging Fields with awk 86
3.3.4.1 Patterns and actions 86
3.3.4.2 Fields 86
3.3.4.3 Setting the field separators 87
3.3.4.4 Printing lines 88
3.3.4.5 Startup and cleanup actions 88
3.4 Summary 89
Chapter 4. Text Processing Tools 91
4.1 Sorting Text 91
4.1.1 Sorting by Lines 91
4.1.2 Sorting by Fields 94
4.1.3 Sorting Text Blocks 96
4.1.4 Sort Efficiency 98
4.1.5 Sort Stability 98
4.1.6 Sort Wrap-Up 99
4.2 Removing Duplicates 99
4.3 Reformatting Paragraphs 100
4.4 Counting Lines, Words, and Characters 101
4.5 Printing 102
4.5.1 Evolution of Printing Technology 104
4.5.2 Other Printing Software 104
4.6 Extracting the First and Last Lines 107
4.7 Summary 110
Chapter 5. Pipelines Can Do Amazing Things 111
5.1 Extracting Data from Structured Text Files 111
5.2 Structured Data for the Web 118
5.3 Cheating at Word Puzzles 124
5.4 Word Lists 126
5.5 Tag Lists 129
5.6 Summary 131
Chapter 6. Variables, Making Decisions, and Repeating Actions 133
6.1 Variables and Arithmetic 133
6.1.1 Variable Assignment and the Environment 133
6.1.2 Parameter Expansion 137
6.1.2.1 Expansion operators 137
6.1.2.2 Positional parameters 139
6.1.2.3 Special variables 141
6.1.3 Arithmetic Expansion 142
6.2 Exit Statuses 144
6.2.1 Exit Status Values 144
6.2.2 if–elif–else–fi 145
6.2.3 Logical NOT, AND, and OR 146
6.2.4 The test Command 148
6.3 The case Statement 153
6.4 Looping 154
6.4.1 for Loops 154
6.4.2 while and until Loops 154
6.4.3 break and continue 155
6.4.4 shift and Option Processing 156
6.5 Functions 159
6.6 Summary 162
Chapter 7. Input and Output, Files, and Command Evaluation 164
7.1 Standard Input, Output, and Error 164
7.2 Reading Lines with read 164
7.3 More About Redirections 167
7.3.1 Additional Redirection Operators 167
7.3.2 File Descriptor Manipulation 169
7.4 The Full Story on printf 171
7.5 Tilde Expansion and Wildcards 176
7.5.1 Tilde Expansion 176
7.5.2 Wildcarding 177
7.5.2.1 Hidden files 179
7.6 Command Substitution 179
7.6.1 Using sed for the head Command 181
7.6.2 Creating a Mailing List 181
7.6.3 Simple Math: expr 183
7.7 Quoting 185
7.8 Evaluation Order and eval 186
7.8.1 The eval Statement 190
7.8.2 Subshells and Code Blocks 191
7.9 Built-in Commands 192
7.9.1 The set Command 196
7.10 Summary 199
Chapter 8. Production Scripts 201
8.1 Path Searching 201
8.2 Automating Software Builds 216
8.3 Summary 246
Chapter 9. Enough awk to Be Dangerous 247
9.1 The awk Command Line 248
9.2 The awk Programming Model 249
9.3 Program Elements 250
9.3.1 Comments and Whitespace 250
9.3.2 Strings and String Expressions 250
9.3.3 Numbers and Numeric Expressions 252
9.3.4 Scalar Variables 256
9.3.5 Array Variables 257
9.3.6 Command-Line Arguments 258
9.3.7 Environment Variables 260
9.4 Records and Fields 260
9.4.1 Record Separators 260
9.4.2 Field Separators 261
9.4.3 Fields 262
9.5 Patterns and Actions 262
9.5.1 Patterns 262
9.5.2 Actions 263
9.6 One-Line Programs in awk 264
9.7 Statements 268
9.7.1 Sequential Execution 268
9.7.2 Conditional Execution 268
9.7.3 Iterative Execution 269
9.7.4 Array Membership Testing 271
9.7.5 Other Control Flow Statements 272
9.7.6 User-Controlled Input 273
9.7.7 Output Redirection 274
9.7.8 Running External Programs 275
9.8 User-Defined Functions 276
9.9 String Functions 279
9.9.1 Substring Extraction 280
9.9.2 Lettercase Conversion 280
9.9.3 String Searching 280
9.9.4 String Matching 281
9.9.5 String Substitution 281
9.9.6 String Splitting 282
9.9.7 String Reconstruction 284
9.9.8 String Formatting 285
9.10 Numeric Functions 288
9.11 Summary 290
Chapter 10. Working with Files 291
10.1 Listing Files 291
10.1.1 Long File Listings 295
10.1.2 Listing File Metadata 296
10.2 Updating Modification Times with touch 297
10.3 Creating and Using Temporary Files 298
10.3.1 The $$ Variable 300
10.3.2 The mktemp Program 300
10.3.3 The /dev/random and /dev/urandom Special Files 301
10.4 Finding Files 303
10.4.1 Finding Files Quickly 303
10.4.2 Finding Where Commands Are Stored 304
10.4.3 The find Command 304
10.4.3.1 Using the find command 304
10.4.3.2 A simple find script 311
10.4.3.3 A complex find script 312
10.4.4 Finding Problem Files 316
10.5 Running Commands: xargs 317
10.6 Filesystem Space Information 319
10.6.1 The df Command 319
10.6.2 The du Command 321
10.7 Comparing Files 323
10.7.1 The cmp and diff Utilities 323
10.7.2 The patch Utility 324
10.7.3 File Checksum Matching 325
10.7.4 Digital Signature Verification 327
10.8 Summary 331
Chapter 11. Extended Example: Merging User Databases 332
11.1 The Problem 332
11.2 The Password Files 333
11.3 Merging Password Files 334
11.3.1 Separating Users by Manageability 335
11.3.2 Managing UIDs 337
11.3.3 Creating User–Old UID–New UID Triples 339
11.4 Changing File Ownership 341
11.5 Other Real-World Issues 345
11.6 Summary 347
Chapter 12. Spellchecking 349
12.1 The spell Program 349
12.2 The Original Unix Spellchecking Prototype 350
12.3 Improving ispell and aspell 351
12.3.1 Private Spelling Dictionaries 352
12.3.2 ispell and aspell 353
12.4 A Spellchecker in awk 355
12.4.1 Introductory Comments 357
12.4.2 Main Body 357
12.4.3 initialize() 357
12.4.4 get_dictionaries() 358
12.4.5 scan_options() 359
12.4.6 load_dictionaries() 360
12.4.7 load_suffixes() 361
12.4.8 order_suffixes() 363
12.4.9 spell_check_line() 364
12.4.10 spell_check_word() 364
12.4.11 strip_suffixes() 365
12.4.12 report_exceptions() 366
12.4.13 Retrospective on Our Spellchecker 371
12.4.14 Efficiency of awk Programs 373
12.5 Summary 374
Chapter 13. Processes 376
13.1 Process Creation 377
13.2 Process Listing 378
13.3 Process Control and Deletion 384
13.3.1 Deleting Processes 385
13.3.2 Trapping Process Signals 387
13.4 Process System-Call Tracing 392
13.5 Process Accounting 396
13.6 Delayed Scheduling of Processes 397
13.6.1 sleep: Delay Awhile 397
13.6.2 at: Delay Until Specified Time 398
13.6.3 batch: Delay for Resource Control 398
13.6.4 crontab: Rerun at Specified Times 399
13.7 The /proc Filesystem 402
13.8 Summary 403
Chapter 14. Shell Portability Issues and Extensions 405
14.1 Gotchas 405
14.2 The bash shopt Command 409
14.3 Common Extensions 413
14.3.1 The select Loop 413
14.3.2 Extended Test Facility 416
14.3.3 Extended Pattern Matching 417
14.3.4 Brace Expansion 419
14.3.5 Process Substitution 419
14.3.6 Indexed Arrays 420
14.3.7 Miscellaneous Extensions 423
14.4 Download Information 426
14.4.1 bash 426
14.4.2 ksh93 428
14.5 Other Extended Bourne-Style Shells 429
14.6 Shell Versions 429
14.7 Shell Initialization and Termination 430
14.7.1 Bourne Shell (sh) Startup 431
14.7.2 Korn Shell Startup 432
14.7.3 Bourne-Again Shell Startup and Termination 432
14.7.4 Z-Shell Startup and Termination 434
14.8 Summary 436
Chapter 15. Secure Shell Scripts: Getting Started 437
15.1 Tips for Secure Shell Scripts 437
15.2 Restricted Shell 440
15.3 Trojan Horses 442
15.4 Setuid Shell Scripts: A Bad Idea 443
15.5 ksh93 and Privileged Mode 445
15.6 Summary 446
Appendix A. Writing Manual Pages 447
Manual Pages for pathfind 448
Manual-Page Syntax Checking 459
Manual-Page Format Conversion 460
Manual-Page Installation 460
Appendix B. Files and Filesystems 461
What Is a File? 461
How Are Files Named? 462
What’s in a Unix File? 465
The Unix Hierarchical Filesystem 467
Filesystem Structure 467
Layered Filesystems 469
Filesystem Implementation Overview 471
Devices as Unix Files 474
How Big Can Unix Files Be? 474
Unix File Attributes 476
File Ownership and Permissions 476
Ownership 476
Permissions 477
Default permissions 479
Permissions in action 479
Directory permissions 482
File Timestamps 484
File Links 485
File Size and Timestamp Variations 487
Other File Metadata 490
Unix File Ownership and Privacy Issues 491
Unix File Extension Conventions 493
Summary 495
Appendix C. Important Unix Commands 497
Shells and Built-in Commands 497
Text Manipulation 498
Files 499
Processes 500
Miscellaneous Programs 500
Bibliography 502
Unix Programmer’s Manuals 502
Programming with the Unix Mindset 502
Awk and Shell 504
Standards 504
Security and Cryptography 505
Unix Internals 506
O’Reilly Books 506
Miscellaneous Books 507
Glossary 508
Index 533
备用文件名
upload/misc_2025_10/IXKXcI5mZnjhFnLAUPaa/E-Books/computer/unixandlinux/9780596005955_classic_shell_scripting_9b50.pdf
备用文件名
nexusstc/Classic Shell Scripting/59ada6d3d001a5a765034c4807de3946.pdf
备用文件名
lgli/_459244.59ada6d3d001a5a765034c4807de3946.pdf
备用文件名
lgrsnf/_459244.59ada6d3d001a5a765034c4807de3946.pdf
备用文件名
zlib/Computers/Operating Systems/Arnold Robbins, Nelson H.F. Beebe/Classic Shell Scripting_1183015.pdf
备选标题
Robbins, A: Shell Scripting
备选作者
Nelson H F Beebe; Arnold Robbins
备选作者
Beebe, Nelson H. F.
备用出版商
Pogue Press
备用版本
Beijing, Boston, Farnham, Sebastopol, Tokyo, California, 2005
备用版本
United States, United States of America
备用版本
O'Reilly Media, Sebastopol, CA, 2005
备用版本
First edition, Sebastopol, CA, 2005
备用版本
Sebastopol, Calif, c2005
元数据中的注释
2011 12 30
元数据中的注释
lg744994
元数据中的注释
producers:
Acrobat Distiller 4.05 for Sparc Solaris
元数据中的注释
{"edition":"1","isbns":["0596005954","9780596005955"],"last_page":534,"publisher":"O'Reilly Media"}
元数据中的注释
Includes bibliographical references (p. 478-483) and index.
备用描述
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 to not only to 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
开源日期
2012-02-04
更多信息……

🚀 快速下载

成为会员以支持书籍、论文等的长期保存。为了感谢您对我们的支持,您将获得高速下载权益。❤️
如果您在本月捐款,您将获得双倍的快速下载次数。

🐢 低速下载

由可信的合作方提供。 更多信息请参见常见问题解答。 (可能需要验证浏览器——无限次下载!)

所有选项下载的文件都相同,应该可以安全使用。即使这样,从互联网下载文件时始终要小心。例如,确保您的设备更新及时。
  • 对于大文件,我们建议使用下载管理器以防止中断。
    推荐的下载管理器:JDownloader
  • 您将需要一个电子书或 PDF 阅读器来打开文件,具体取决于文件格式。
    推荐的电子书阅读器:Anna的档案在线查看器ReadEraCalibre
  • 使用在线工具进行格式转换。
    推荐的转换工具:CloudConvertPrintFriendly
  • 您可以将 PDF 和 EPUB 文件发送到您的 Kindle 或 Kobo 电子阅读器。
    推荐的工具:亚马逊的“发送到 Kindle”djazz 的“发送到 Kobo/Kindle”
  • 支持作者和图书馆
    ✍️ 如果您喜欢这个并且能够负担得起,请考虑购买原版,或直接支持作者。
    📚 如果您当地的图书馆有这本书,请考虑在那里免费借阅。