没有合适的资源?快使用搜索试试~ 我知道了~
首页Sed & Awk 101 Hacks
Sed & Awk 101 Hacks
5星 · 超过95%的资源 需积分: 10 23 下载量 124 浏览量
更新于2023-03-16
评论
收藏 5.6MB PDF 举报
Linux 中 Sed Awk 的操作。If you are a developer, or system administrator, or database administrator, or IT manager, or just someone who spends a significant amount of time on UNIX / Linux, you should become proficient in Sed and Awk. Sed and Awk are two great utilities that can solve a lot of complex tasks quickly with only a few lines of code--in most cases, with just a single line of code.
资源详情
资源评论
资源推荐
Knowledge is not one man's Entity
Book Hacked by VELOCIRAPTOR
Sed and Awk 101 Hacks
Table of Contents
Introduction ........................................................ 6
Chapter 1: Sed Syntax and Basic Commands ......... 9
1. Sed Command Syntax ............................................... 10
2. Sed Scripting Flow ................................................... 12
3. Print Pattern Space (p command) ............................. 13
4. Delete Lines (d command) ....................................... 17
5. Write Pattern Space to File (w command) ................. 19
Chapter 2. Sed Substitute Command ................... 23
6. Sed Substitute Command Syntax .............................. 23
7. Global Flag (g flag) .................................................. 24
8. Number Flag (1,2,3.. flag) ........................................ 25
9. Print Flag (p flag) .................................................... 26
10. Write Flag (w flag) ................................................. 26
11. Ignore Case Flag (i flag) ......................................... 27
12. Execute Flag (e flag) .............................................. 28
13. Combine Sed Substitution Flags ............................. 29
14. Sed Substitution Delimiter ..................................... 29
15. Multiple Substitute Commands Affecting the Same
Line ............................................................................. 30
16. Power of & - Get Matched Pattern .......................... 32
17. Substitution Grouping (Single Group) ..................... 32
18. Substitution Grouping (Multiple Group) .................. 34
19. Gnu Sed Only Replacement String Flags ................. 36
Chapter 3. Regular Expressions .......................... 39
20. Regular Expression Fundamentals ........................... 39
21. Additional Regular Expressions ............................... 42
22. Sed Substitution Using Regular Expression ............. 45
2
Book Hacked by VELOCIRAPTOR
BOOK HACKED BY VELOCIRAPTOR
Sed and Awk 101 Hacks
Chapter 4. Sed Execution ................................... 47
23. Multiple Sed Commands in Command Line .............. 47
24. Sed Script Files ...................................................... 48
25. Sed Comments ....................................................... 49
26. Sed as an Interpreter ............................................. 49
27. Modifying the Input File Directly ............................. 51
Chapter 5. Additional Sed Commands .................. 53
28. Append Line After (a command) ............................. 53
29. Insert Line Before (i command) .............................. 54
30. Change Line (c command) ...................................... 55
31. Combine a, i, and c Commands ............................... 56
32. Print Hidden Characters (l command) ..................... 57
33. Print Line Numbers (= command) ........................... 58
34. Change Case (using the y 'transform' command) ..... 59
35. Multiple Files in Command Line .............................. 60
36. Quit Sed (q command) ........................................... 61
37. Read from File (r command) ................................... 62
38. Simulating Unix commands in sed (cat, grep, head) 62
39. Sed Command Line Options ..................................... 64
40. Print Pattern Space (n command) ........................... 66
Chapter 6. Sed Hold and Pattern Space Commands
......................................................................... 68
41. Swap Pattern Space with Hold Space (x command) . . 69
42. Copy Pattern Space to Hold Space (h command) ..... 70
43. Append Pattern Space to Hold Space (H command) . 71
44. Copy Hold Space to Pattern Space (g command) ..... 74
45. Append Hold Space to Pattern Space (G command) . . 75
Chapter 7. Sed Multi-Line Commands and loops . . 77
46. Append Next Line to Pattern Space (N command) . . . 77
47. Print 1st Line in MultiLine (P command) .................. 79
48. Delete 1st Line in MultiLine (D command) ............... 80
49. Loop and Branch (b command and :label) ............... 82
50. Loop Using t command ........................................... 84
3
Sed and Awk 101 Hacks
Chapter 8. Awk Syntax and Basic Commands ...... 86
51. Awk Command Syntax ........................................... 88
52. Awk Program Structure (BEGIN, body, END block) ... 90
53. Print Command ...................................................... 95
54. Pattern Matching ................................................... 97
Chapter 9. Awk Built-in Variables ....................... 98
55. FS - Input Field Separator ...................................... 98
56. OFS - Output Field Separator ................................. 99
57. RS - Record Separator .......................................... 101
58. ORS - Output Record Separator ............................ 103
59. NR - Number of Records ....................................... 105
60. FILENAME – Current File Name .............................. 105
61. FNR - File "Number of Record" ............................... 107
Chapter 10. Awk Variables and Operators ......... 110
62. Variables ............................................................. 110
63. Unary Operators .................................................. 111
64. Arithmetic Operators ........................................... 115
65. String Operator ................................................... 116
66. Assignment Operators ......................................... 117
67. Comparison Operators ......................................... 119
68. Regular Expression Operators ............................... 123
Chapter 11. Awk Conditional Statements and Loops
....................................................................... 124
69. Simple If Statement ............................................. 124
70. If Else Statement ................................................. 125
71. While Loop .......................................................... 127
72. Do-While Loop ..................................................... 129
73. For Loop Statement ............................................. 130
74. Break Statement .................................................. 132
75. Continue Statement ............................................. 134
76. Exit Statement .................................................... 136
Chapter 12. Awk Associative Arrays ................. 138
77. Assigning Array Elements ..................................... 138
78. Referring to Array Elements ................................. 140
4
Sed and Awk 101 Hacks
79. Browse the Array using For Loop .......................... 141
80. Delete Array Element ........................................... 143
81. Multi Dimensional Array ....................................... 144
82. SUBSEP - Subscript Separator .............................. 147
83. Sort Array Values using asort ............................... 148
84. Sort Array Indexes using asorti ............................ 151
Chapter 13. Additional Awk Commands ............ 153
85. Pretty Printing Using printf .................................. 153
86. Built-in Numeric Functions ................................... 165
87. Random Number Generator .................................. 168
88. Generic String Functions ...................................... 171
89. GAWK/NAWK String Functions .............................. 174
90. GAWK String Functions ........................................ 178
91. Argument Processing (ARGC, ARGV, ARGIND) ........ 178
92. OFMT .................................................................. 182
93. GAWK Built-in Environment Variables ................... 184
94. Awk Profiler - pgawk ............................................ 187
95. Bit Manipulation .................................................. 189
96. User Defined Functions ........................................ 192
97. Language Independent Output (Internationalization)
................................................................................. 195
98. Two Way Communication ..................................... 199
99. System Function .................................................. 201
100. Timestamp Functions ......................................... 202
101. getline Command ............................................... 206
5
剩余209页未读,继续阅读
二为什么比1大
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 27页智慧街道信息化建设综合解决方案.pptx
- 计算机二级Ms-Office选择题汇总.doc
- 单链表的插入和删除实验报告 (2).docx
- 单链表的插入和删除实验报告.pdf
- 物联网智能终端项目设备管理方案.pdf
- 如何打造品牌的模式.doc
- 样式控制与页面布局.pdf
- 武汉理工Java实验报告(二).docx
- 2021线上新品消费趋势报告.pdf
- 第3章 Matlab中的矩阵及其运算.docx
- 基于Web的人力资源管理系统的必要性和可行性.doc
- 基于一阶倒立摆的matlab仿真实验.doc
- 速运公司物流管理模式研究教材
- 大数据与管理.pptx
- 单片机课程设计之步进电机.doc
- 大数据与数据挖掘.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1