没有合适的资源?快使用搜索试试~ 我知道了~
shell从入门到精通pdf
需积分: 47 155 下载量 134 浏览量
2017-11-28
15:18:53
上传
评论
收藏 1.89MB PDF 举报
温馨提示
关于本文档 文档名称 Shell 从入门到精通 腾讯课堂直播 http://opsdev.ke.qq.com 博客 http://lizhenliang.blog.51cto.com GitHub https://github.com/lizhenliang/Shell-Python-Document QQ 技术群 323779636(Shell/Python 运维开发群) 说明 本文档均为个人经验总结,转发请保留出处,抵制不道德行为。 文档会不定期修改或新增知识点,请关注群状态。 最后更新时间 2017-04-24
资源推荐
资源详情
资源评论









关于本文档
文档名称
Shell 从入门到精通
腾讯课堂直播
http://opsdev.ke.qq.com
博客
http://lizhenliang.blog.51cto.com
GitHub
https://github.com/lizhenliang/Shell-Python-Document
QQ 技术群
323779636(Shell/Python 运维开发群)
说明
本文档均为个人经验总结,转发请保留出处,抵制不道德行为。
文档会不定期修改或新增知识点,请关注群状态。
最后更新时间
2017-04-24
学习目标
熟悉 Linux 系统常用命令与工具,掌握 Shell 脚本语言语法结构,能独立编写 Shell 脚本,完成自动
化运维常规任务,提高工作效率,为以后学习其他语言打下坚实的基础。
目标人群
运维工程师、开发工程师、Linux 系统爱好者或已经具备其他编程语言的人群。
操作系统
本文档实验均采用 CentOS7_X64 系统。需要注意的是,与 CentOS6 或者 Ubuntu 相比,个别命令使用
方法会有点不同。

目录
第一章 Shell 基础知识 ...................................................................... 8
1.1 Shell 简介 ............................................................................................................................................................ 8
1.2 Shell 基本分两大类 ............................................................................................................................................ 9
1.3 第一个 Shell 脚本 ............................................................................................................................................... 9
1.4 Shell 变量 ............................................................................................................................................................ 9
1.5 变量引用 ............................................................................................................................................................. 12
1.6 双引号和单引号 ................................................................................................................................................. 13
1.7 注释..................................................................................................................................................................... 14
第二章 Shell 字符串处理之${} .............................................................. 14
2.1 获取字符串长度 ................................................................................................................................................. 14
2.2 字符串切片 ......................................................................................................................................................... 14
2.3 替换字符串 ......................................................................................................................................................... 15
2.4 字符串截取 ......................................................................................................................................................... 15
2.5 变量状态赋值 ..................................................................................................................................................... 16
2.6 字符串颜色 ......................................................................................................................................................... 16
第三章 Shell 表达式与运算符 ............................................................... 17
3.1 条件表达式 ......................................................................................................................................................... 17
3.2 整数比较符 ......................................................................................................................................................... 18
3.3 字符串比较符 ..................................................................................................................................................... 18
3.4 文件测试 ............................................................................................................................................................. 19
3.5 布尔运算符 ......................................................................................................................................................... 19
3.6 逻辑判断符 ......................................................................................................................................................... 20
3.7 整数运算 ............................................................................................................................................................. 20
3.8 其他运算工具(let/expr/bc) ....................................................................................................................... 21
3.9 Shell 括号用途总结 .......................................................................................................................................... 22
第四章 Shell 流程控制 ..................................................................... 23
4.1 if 语句 ................................................................................................................................................................ 23
4.2 for 语句 .............................................................................................................................................................. 25
4.3 while 语句 .......................................................................................................................................................... 26
4.4 break 和 continue 语句 .................................................................................................................................... 28
4.5 case 语句 ............................................................................................................................................................ 29
4.6 select 语句 ........................................................................................................................................................ 30
第五章 Shell 函数与数组 ................................................................... 32
5.1 函数..................................................................................................................................................................... 32

5.2 数组..................................................................................................................................................................... 33
第六章 Shell 正则表达式 ................................................................... 35
第七章 Shell 文本处理三剑客 ............................................................... 38
7.1 grep..................................................................................................................................................................... 38
7.2 sed....................................................................................................................................................................... 42
7.2.1 匹配打印(p) ........................................................................................................................................... 44
7.2.2 匹配删除(d) ........................................................................................................................................... 45
7.2.3 替换(s///) ............................................................................................................................................. 46
7.2.4 多重编辑(-e) ......................................................................................................................................... 49
7.2.5 添加新内容(a、i 和 c) ......................................................................................................................... 50
7.2.6 读取文件并追加到匹配行后(r) ........................................................................................................... 51
7.2.7 将匹配行写到文件(w) ........................................................................................................................... 52
7.2.8 读取下一行(n 和 N) ............................................................................................................................... 52
7.2.9 打印和删除模式空间第一行(P 和 D) ................................................................................................... 55
7.2.10 保持空间操作(h 与 H、g 与 G 和 x) ................................................................................................... 55
7.2.11 标签(:、b 和 t) ................................................................................................................................... 57
7.2.12 忽略大小写匹配(I) ............................................................................................................................. 58
7.2.13 获取总行数(#) ..................................................................................................................................... 58
8.3 awk....................................................................................................................................................................... 58
8.3.1 选项 ............................................................................................................................................................. 59
8.3.2 模式 ............................................................................................................................................................. 60
8.3.3 内置变量 ..................................................................................................................................................... 65
8.3.4 操作符 ......................................................................................................................................................... 69
8.3.5 流程控制 ..................................................................................................................................................... 73
8.3.6 数组 ............................................................................................................................................................. 76
8.3.7 内置函数 ..................................................................................................................................................... 80
8.3.8 I/O 语句 ...................................................................................................................................................... 84
8.3.9 printf 语句 ................................................................................................................................................ 87
8.3.10 自定义函数 ............................................................................................................................................... 88
8.3.11 需求案例 ................................................................................................................................................... 88
第八章 Shell 标准输入、输出和错误 ......................................................... 94
8.1 标准输入、输出和错误 ..................................................................................................................................... 94
8.2 重定向符号 ......................................................................................................................................................... 94
8.3 重定向输出 ......................................................................................................................................................... 94
8.4 重定向输入 ......................................................................................................................................................... 95

8.5 重定向标准输出和标准错误 ............................................................................................................................. 95
8.6 重定向到空设备 ................................................................................................................................................. 96
8.7 read 命令 ............................................................................................................................................................ 96
第九章 Shell 信号发送与捕捉 ............................................................... 98
9.1 Linux 信号类型 .................................................................................................................................................. 98
9.2 kill 命令 .......................................................................................................................................................... 100
9.3 trap 命令 .......................................................................................................................................................... 100
第十章 Shell 编程时常用的系统文件 ........................................................ 102
10.1 Linux 系统目录结构 ...................................................................................................................................... 102
10.2 环境变量文件 ................................................................................................................................................. 102
10.3 系统配置文件 ................................................................................................................................................. 103
10.4 /dev 目录 ........................................................................................................................................................ 104
10.5 /proc 目录 ...................................................................................................................................................... 104
10.5.1 /proc ....................................................................................................................................................... 104
10.5.2 /proc/net ............................................................................................................................................... 105
10.5.3 /proc/sys ............................................................................................................................................... 105
第十一章 Shell 常用命令与工具 ............................................................ 108
11.1 ls..................................................................................................................................................................... 108
11.2 echo................................................................................................................................................................. 108
11.3 printf ............................................................................................................................................................. 109
11.4 cat................................................................................................................................................................... 110
11.5 tac................................................................................................................................................................... 110
11.6 rev................................................................................................................................................................... 111
11.7 wc..................................................................................................................................................................... 111
11.8 cp..................................................................................................................................................................... 111
11.9 mkdir ............................................................................................................................................................... 112
11.10 mv................................................................................................................................................................... 112
11.11 rename ........................................................................................................................................................... 112
11.12 dirname ......................................................................................................................................................... 112
11.13 basename ....................................................................................................................................................... 113
11.14 du................................................................................................................................................................... 113
11.15 cut................................................................................................................................................................. 114
11.16 tr................................................................................................................................................................... 114
11.17 stat ............................................................................................................................................................... 115
11.18 seq................................................................................................................................................................. 115
剩余164页未读,继续阅读
资源评论


jy_fangzp
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- content_1739943630900.djvu
- 管家婆辉煌食品普及版TOP12.9.zip
- 管家婆辉煌食品普及版TOP12.71.zip
- 管家婆辉煌食品版TOP13.22.zip
- COMSOL激光加热技术:聚合物材料与人体皮肤组织的探索与应用,利用Comsol技术激光加热聚合物材料在人体皮肤组织中的应用,comsol激光加热聚合物材料,人体皮肤组织 ,comsol;激光加热;聚
- MATLAB中的光学仿真及数值模拟研究:基于4f系统下透镜的传递函数与菲涅尔衍射分析,MATLAB中的光学仿真与4f系统数值模拟:菲涅尔衍射函数与透镜传递函数的计算研究,MATLAB 光学仿真,4f系
- Win10Win11系统更新管理
- 基于Koopman算子的非线性模型预测控制-Nonlinear-Model-Predictive-Control-Using-Koopman-Operator
- 管家婆辉煌食品普及版TOP12.91.zip
- 管家婆辉煌食品普及版TOP12.81.zip
- 基于粒子群算法的BP神经网络优化多输入输出预测代码注释详备支持Excel数据存储替换,基于粒子群算法优化的BP神经网络多输入多输出预测系统-详细注释代码与Excel数据存储,基于粒子群算法优化BP神
- 管家婆辉煌食品普及版TOP13.0.zip
- 集团智慧水务整体解决方案(174页).docx
- “智慧园区”可行性研究分析报告(164页).docx
- 市级智慧新区数据融合服务平台建设方案(180页).docx
- 2024 分布式可调节资源区块链聚合管控技术及应用(虚拟电厂运营).pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
