没有合适的资源?快使用搜索试试~ 我知道了~
linux shell编程(abs guide, advanced bash-script guid)
5星 · 超过95%的资源 需积分: 10 18 下载量 176 浏览量
2013-05-24
18:14:47
上传
评论 1
收藏 2.5MB PDF 举报
温馨提示
试读
865页
书名叫abs guide,linux shell编程书籍,个人认为非常非常好)。就是国内基本上只有淘宝上能买到,但是贵:( 看电子版的吧
资源推荐
资源详情
资源评论
Advanced Bash-Scripting Guide
An in-depth exploration of the art of shell scripting
Mendel Cooper
<thegrendel.abs@gmail.com>
6.2
17 March 2010
Revision History
Revision 6.0 23 Mar 2009 Revised by: mc
'THIMBLEBERRY' release: Major Update.
Revision 6.1 30 Sep 2009 Revised by: mc
'BUFFALOBERRY' release: Minor Update.
Revision 6.2 17 Mar 2010 Revised by: mc
'ROWANBERRY' release
This tutorial assumes no previous knowledge of scripting or programming, but progresses rapidly toward an
intermediate/advanced level of instruction . . . all the while sneaking in little nuggets of UNIX® wisdom and
lore. It serves as a textbook, a manual for self-study, and a reference and source of knowledge on shell
scripting techniques. The exercises and heavily-commented examples invite active reader participation, under
the premise that the only way to really learn scripting is to write scripts.
This book is suitable for classroom use as a general introduction to programming concepts.
Dedication
For Anita, the source of all the magic
Table of Contents
Chapter 1. Shell Programming!.........................................................................................................................1
Chapter 2. Starting Off With a Sha-Bang........................................................................................................3
2.1. Invoking the script............................................................................................................................6
2.2. Preliminary Exercises.......................................................................................................................6
Part 2. Basics.......................................................................................................................................................7
Chapter 3. Special Characters...........................................................................................................................8
Chapter 4. Introduction to Variables and Parameters..................................................................................29
4.1. Variable Substitution......................................................................................................................29
4.2. Variable Assignment.......................................................................................................................32
4.3. Bash Variables Are Untyped..........................................................................................................33
4.4. Special Variable Types...................................................................................................................34
Chapter 5. Quoting...........................................................................................................................................40
5.1. Quoting Variables...........................................................................................................................40
5.2. Escaping..........................................................................................................................................42
Chapter 6. Exit and Exit Status.......................................................................................................................48
Chapter 7. Tests................................................................................................................................................51
7.1. Test Constructs...............................................................................................................................51
7.2. File test operators............................................................................................................................58
7.3. Other Comparison Operators..........................................................................................................61
7.4. Nested if/then Condition Tests.......................................................................................................67
7.5. Testing Your Knowledge of Tests..................................................................................................67
Chapter 8. Operations and Related Topics....................................................................................................69
8.1. Operators.........................................................................................................................................69
8.2. Numerical Constants.......................................................................................................................75
8.3. The Double-Parentheses Construct.................................................................................................77
8.4. Operator Precedence.......................................................................................................................78
Part 3. Beyond the Basics.................................................................................................................................81
Chapter 9. Another Look at Variables...........................................................................................................82
9.1. Internal Variables............................................................................................................................82
9.2. Typing variables: declare or typeset.............................................................................................101
9.2.1. Another use for declare.......................................................................................................103
9.3. $RANDOM: generate random integer..........................................................................................103
Chapter 10. Manipulating Variables.............................................................................................................115
10.1. Manipulating Strings...................................................................................................................115
10.1.1. Manipulating strings using awk........................................................................................122
10.1.2. Further Reference..............................................................................................................123
10.2. Parameter Substitution................................................................................................................123
Advanced Bash-Scripting Guide
i
Table of Contents
Chapter 11. Loops and Branches..................................................................................................................133
11.1. Loops..........................................................................................................................................133
11.2. Nested Loops..............................................................................................................................146
11.3. Loop Control...............................................................................................................................147
11.4. Testing and Branching................................................................................................................150
Chapter 12. Command Substitution.............................................................................................................159
Chapter 13. Arithmetic Expansion................................................................................................................165
Chapter 14. Recess Time................................................................................................................................166
Part 4. Commands..........................................................................................................................................167
Chapter 15. Internal Commands and Builtins.............................................................................................175
15.1. Job Control Commands..............................................................................................................204
Chapter 16. External Filters, Programs and Commands...........................................................................209
16.1. Basic Commands........................................................................................................................209
16.2. Complex Commands...................................................................................................................214
16.3. Time / Date Commands..............................................................................................................224
16.4. Text Processing Commands........................................................................................................228
16.5. File and Archiving Commands...................................................................................................250
16.6. Communications Commands......................................................................................................269
16.7. Terminal Control Commands.....................................................................................................283
16.8. Math Commands.........................................................................................................................284
16.9. Miscellaneous Commands..........................................................................................................295
Chapter 17. System and Administrative Commands..................................................................................309
17.1. Analyzing a System Script..........................................................................................................338
Part 5. Advanced Topics.................................................................................................................................340
Chapter 18. Regular Expressions..................................................................................................................342
18.1. A Brief Introduction to Regular Expressions..............................................................................342
18.2. Globbing.....................................................................................................................................346
Chapter 19. Here Documents.........................................................................................................................348
19.1. Here Strings................................................................................................................................358
Chapter 20. I/O Redirection...........................................................................................................................362
20.1. Using exec...................................................................................................................................365
20.2. Redirecting Code Blocks............................................................................................................368
20.3. Applications................................................................................................................................373
Chapter 21. Subshells.....................................................................................................................................375
Advanced Bash-Scripting Guide
ii
Table of Contents
Chapter 22. Restricted Shells.........................................................................................................................380
Chapter 23. Process Substitution...................................................................................................................382
Chapter 24. Functions....................................................................................................................................386
24.1. Complex Functions and Function Complexities.........................................................................390
24.2. Local Variables...........................................................................................................................400
24.2.1. Local variables and recursion............................................................................................401
24.3. Recursion Without Local Variables............................................................................................403
Chapter 25. Aliases.........................................................................................................................................407
Chapter 26. List Constructs...........................................................................................................................410
Chapter 27. Arrays.........................................................................................................................................413
Chapter 28. Indirect References....................................................................................................................442
Chapter 29. /dev and /proc.............................................................................................................................446
29.1. /dev..............................................................................................................................................446
29.2. /proc............................................................................................................................................448
Chapter 30. Of Zeros and Nulls.....................................................................................................................455
Chapter 31. Debugging...................................................................................................................................459
Chapter 32. Options........................................................................................................................................469
Chapter 33. Gotchas.......................................................................................................................................472
Chapter 34. Scripting With Style..................................................................................................................481
34.1. Unofficial Shell Scripting Stylesheet..........................................................................................481
Chapter 35. Miscellany...................................................................................................................................484
35.1. Interactive and non-interactive shells and scripts.......................................................................484
35.2. Shell Wrappers............................................................................................................................485
35.3. Tests and Comparisons: Alternatives..........................................................................................490
35.4. A script calling itself (recursion)................................................................................................491
35.5. "Colorizing" Scripts....................................................................................................................493
35.6. Optimizations..............................................................................................................................506
35.7. Assorted Tips..............................................................................................................................507
35.7.1. Ideas for more powerful scripts.........................................................................................507
35.7.2. Widgets..............................................................................................................................517
35.8. Security Issues............................................................................................................................519
35.8.1. Infected Shell Scripts.........................................................................................................519
35.8.2. Hiding Shell Script Source................................................................................................520
35.8.3. Writing Secure Shell Scripts.............................................................................................520
35.9. Portability Issues.........................................................................................................................520
Advanced Bash-Scripting Guide
iii
Table of Contents
Chapter 35. Miscellany
35.9.1. A Test Suite.......................................................................................................................521
35.10. Shell Scripting Under Windows...............................................................................................522
Chapter 36. Bash, versions 2, 3, and 4..........................................................................................................523
36.1. Bash, version 2............................................................................................................................523
36.2. Bash, version 3............................................................................................................................527
36.2.1. Bash, version 3.1...............................................................................................................530
36.2.2. Bash, version 3.2...............................................................................................................530
36.3. Bash, version 4............................................................................................................................531
Chapter 37. Endnotes.....................................................................................................................................538
37.1. Author's Note..............................................................................................................................538
37.2. About the Author........................................................................................................................538
37.3. Where to Go For Help.................................................................................................................538
37.4. Tools Used to Produce This Book..............................................................................................539
37.4.1. Hardware...........................................................................................................................539
37.4.2. Software and Printware.....................................................................................................539
37.5. Credits.........................................................................................................................................539
37.6. Disclaimer...................................................................................................................................541
Bibliography....................................................................................................................................................542
Appendix A. Contributed Scripts..................................................................................................................550
Appendix B. Reference Cards........................................................................................................................747
Appendix C. A Sed and Awk Micro-Primer................................................................................................752
C.1. Sed................................................................................................................................................752
C.2. Awk..............................................................................................................................................755
Appendix D. Exit Codes With Special Meanings.........................................................................................758
Appendix E. A Detailed Introduction to I/O and I/O Redirection.............................................................759
Appendix F. Command-Line Options...........................................................................................................761
F.1. Standard Command-Line Options................................................................................................761
F.2. Bash Command-Line Options......................................................................................................762
Appendix G. Important Files.........................................................................................................................764
Appendix H. Important System Directories.................................................................................................765
Appendix I. An Introduction to Programmable Completion.....................................................................767
Appendix J. Localization................................................................................................................................770
Advanced Bash-Scripting Guide
iv
剩余864页未读,继续阅读
资源评论
- xx_sck2015-08-1432个赞,内容很好很强大,非常详细。
- qq6178672122014-07-18很全,很细。感谢楼主分享!
- JSWLIVE2014-05-21太好了,内容很好
kittaaron
- 粉丝: 45
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 同等学力申硕考试 组合数学
- 同等学力 离散数学与组合数学
- 50条最常用Linux系统命令大全手册
- 斯沃数控仿真软件7.2版数控加工中心车床铣床编程仿真模拟教程斯沃系统手册可编程序控制器系统(ABPLC)说明
- 2023NOC软件创意编程赛项真题-python小高初赛
- 2024安全信息安全与评估
- 斯沃数控仿真软件7.2版数控加工中心车床铣床编程仿真模拟教程斯沃系统手册DASEN-9i-连接手册PLC-手册
- SpringBoot集成MyBatis-Plus
- 基于python-contrib-opencv,dlib,pyqt5实现电脑端摄像头读取视频,实时人脸录入,人脸识别等功能
- 斯沃数控仿真软件7.2版数控加工中心车床铣床编程仿真模拟教程斯沃系统手册DASEN-3i-h连接手册PLC手册
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功