finallyeva / Shell_Scripts

Shell Scripts examples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

image
图书《Linux Shell核心编程指南》的素材脚本。

《Linux Shell Scripts manual》 materials.

The book's index:

第1章 从这里开始,起飞了 (page 1) Chaper1 Now begin!

1.1 脚本文件的书写格式 (page 1) The standard of Shell script.

1.2 脚本文件的各种执行方式 (page 3) How to run a Shell script.

1.3 如何在脚本文件中实现数据的输入与输出 (page 6) How read and write data through script.

1.4 输入与输出的重定向 (page 17) data redirection.

1.5 各种引号的正确使用姿势 (page 24) Quotation marks.

1.6 千变万化的变量 (page 28) Variables.

1.7 数据过滤与正则表达式 (page 33) Regular Expression.

1.8 各式各样的算术运算 (page 40) Basic operation.


第2章 人工智能,很人工、很智能的脚本 (page 46) Chapter2 So smart script!

2.1 智能化脚本的基础之测试 (page 46) Test.

2.2 字符串的判断与比较 (page 47) Compare.

2.3 整数的判断与比较 (page 49) Integer comparison.

2.4 文件属性的判断与比较 (page 51) test file/directory.

2.5 探究[[]]和[]的区别 (page 55) Difference between [[]] and [].

2.6 实战案例:系统性能监控脚本 (page 60) Example: Monitoring system performance.

2.7 实战案例:单分支if语句 (page 62) Example: Simple examples of if.

2.8 实战案例:双分支if语句 (page 68) Example: More examples of if.

2.9 实战案例:如何监控HTTP服务状态 (page 72) Example: How to monitor http status.

2.10 实战案例:多分支if语句 (page 81) Example: Advanced if synopsis.

2.11 实战案例:简单、高效的case语句 (page 87) Example: Case synopsis.

2.12 实战案例:编写Nginx启动脚本 (page 92) Example: Nginx init.d script.

2.13 揭秘模式匹配与通配符、扩展通配符 (page 94) Pattern Martching、expended pattern.

2.14 Shell小游戏之石头剪刀布 (page 100) Game:Rock-paper-scissors.


第3章 根本停不下来的循环和中断控制 (page 104) Chapter3 loop and break

3.1 玩转for循环语句 (page 104) for statement.

3.2 实战案例:猴子吃香蕉的问题 (page 114) Example: Monkey's problem.

3.3 实战案例:进化版HTTP状态监控脚本 (page 116) Example: Monitoring http status v2.

3.4 神奇的循环嵌套 (page 117) Nested loop.

3.5 非常重要的IFS (page 124) Important variable IFS.

3.6 实战案例:while循环 (page 130) Example: while statement.

3.7 Shell小游戏之猜随机数字 (page 134) Game: Guess the number.

3.8 实战案例:如何通过read命令读取文件中的数据 (page 136) Example: read data

3.9 until和select循环 (page 140) untile and select.

3.10 中断与退出控制 (page 143) break and exit.

3.11 Shell小游戏之机选双色球 (page 149) Game: Lottery.


第4章 请开始你的表演,数组、Subshell与函数 (page 152) Chapter4 Array、subshell and function.

4.1 强悍的数组 (page 152) Array.

4.2 实战案例:斐波那契数列 (page 157) Example: Fibonacci sequence.

4.3 实战案例:网站日志分析脚本 (page 159) Example: Analysis web log.

4.4 常犯错误的SubShell (page 164) The subshell.

4.5 启动进程的若干种方式 (page 172) How to run a new program.

4.6 非常实用的函数功能 (page 176) Function.

4.7 变量的作用域与return返回值 (page 179) Scope of variable、return.

4.8 实战案例:多进程的ping脚本 (page 185) Example: Multi process script for ping.

4.9 控制进程数量的核心技术——文件描述符和命名管道 (page 187) File descriptor and named pipe.

4.10 实战案例:一键源码部署LNMP的脚本 (page 197) Example: Install LNMP software through Shell.

4.11 递归函数 (page 204) Recursive function.

4.12 排序算法之冒泡排序 (page 206) Bubble sort.

4.13 排序算法之快速排序 (page 209) Quick sort.

4.14 排序算法之插入排序 (page 213) Insertion sort.

4.15 排序算法之计数排序 (page 215) Counting sort.

4.16 Shell小游戏之单词拼接puzzle (page 218) Game: puzzle.


第5章 一大波脚本技巧正向你走来 (page 221) Chapter5 Skill.

5.1 Shell八大扩展功能之花括号 (page 221) {}Curly braces.

5.2 Shell八大扩展功能之波浪号 (page 223) ~Tilde.

5.3 Shell八大扩展功能之变量替换 (page 224) Variable substitution.

5.4 Shell八大扩展功能之命令替换 (pgae 234) Command substitution.

5.5 Shell八大扩展功能之算术替换 (page 234) Operation substitution.

5.6 Shell八大扩展功能之进程替换 (page 236) Process substitution.

5.7 Shell八大扩展功能之单词切割 (page 238) Word spliting.

5.8 Shell八大扩展功能之路径替换 (page 239) Path substitution.

5.9 实战案例:生成随机密码的若干种方式 (page 240) Example: Random password.

5.10 Shell解释器的属性与初始化命令行终端 (page 247) Bash attribution.

5.11 trap信号捕获 (page 257) trap.

5.12 实战案例:电子时钟 (page 259) Example: Clock.

5.13 Shell小游戏之抓住小老鼠算你赢 (page 263) Game: Catch a mouse.

5.14 实战案例:脚本排错技巧 (page 267) Example: debug.

5.15 实战案例:Shell版本的进度条功能 (page 270) Example: Progress bar.

5.16 再谈参数传递之xargs (page 276) xargs

5.17 使用shift移动位置参数 (page 280) shift.

5.18 实战案例:Nginx日志切割脚本 (page 281) Example: Nginx log.


第6章 上古神兵利器sed (page 285) Chapter6 sed.

6.1 sed基本指令 (page 285) Basic syntax.

6.2 sed高级指令 (page 305) Advanced sed.

6.3 实战案例:自动化配置vsftpd脚本 (page 318) Example: Configure vsftpd serivce.

6.4 实战案例:自动化配置DHCP脚本 (page 325) Example: Configure dhcp service.

6.5 实战案例:自动化克隆KVM虚拟机脚本 (page 329) Example: Clone kvm virtual machine.

6.6 实战案例:通过libguestfs管理KVM虚拟机脚本 (page 337) Example: libguestfs.

6.7 实战案例:自动化配置SSH安全策略脚本 (pgae 343) Example: Configure ssh service.

6.8 实战案例:基于GRUB配置文件修改内核启动参数脚本 (page 345) Example: Modify grub.cfg.

6.9 实战案例:网络爬虫脚本 (page 348) Example: Internet Worm.

6.10 Shell小游戏之点名抽奖器 (page 354) Game:Roll call.


第7章 不可思议的编程语言awk (page 356) Chapter7 awk.

7.1 awk基础语法 (page 356) awk syntax.

7.2 awk条件判断 (page 374) if statement.

7.3 awk数组与循环 (page 379) array and loop.

7.4 awk函数 (page 388) awk funcation.

7.5 实战案例:awk版网站日志分析 (page 398) Example: Analysis web log.

7.6 实战案例:监控网络连接状态 (page 403) Example: Monitoring network connection status.

7.7 实战案例:获取SSH暴力破解攻击黑名单列表 (page 412) Example: Generate block user file.

7.8 实战案例:性能监控脚本 (page 418) Example: Monitoring system performance.

7.9 实战案例:数据库监控脚本 (page 420) Example: Monitoring MySQL.

7.10 实战案例:awk版网络爬虫 (page 429) Example: Internet Worm.

About

Shell Scripts examples

License:Apache License 2.0


Languages

Language:Shell 100.0%