linux-shell高级编程-操作变量串
2017-11-21 23:25
561 查看
1 ${#string} 返回string的长度
2 ${string:position} 在string中 为位置$position 之后提取子串
3 ${string:position:length} 在string中 为位置$position 之后开始提取长度为length的子串
4 ${string#substring} 从string开头 开始删除最短匹配 substring子串
5 ${string##substring} 从string开头 开始删除最长匹配 substring子串
6 ${string%substring} 从string结尾 开始删除最短匹配 substring子串
7 ${string%%substring} 从string结尾 开始删除最长匹配 substring子串
8 ${string/substring/replace} 使用replace 代替 在string中匹配的substring
9 ${string/#substring/replace} 使用replace 代替 以string前缀匹配的substring
10 ${string/%substring/replace} 使用replace 代替 在string后缀中匹配的substring
原始内容可使用 man bash 查看
2 ${string:position} 在string中 为位置$position 之后提取子串
3 ${string:position:length} 在string中 为位置$position 之后开始提取长度为length的子串
4 ${string#substring} 从string开头 开始删除最短匹配 substring子串
5 ${string##substring} 从string开头 开始删除最长匹配 substring子串
6 ${string%substring} 从string结尾 开始删除最短匹配 substring子串
7 ${string%%substring} 从string结尾 开始删除最长匹配 substring子串
8 ${string/substring/replace} 使用replace 代替 在string中匹配的substring
9 ${string/#substring/replace} 使用replace 代替 以string前缀匹配的substring
10 ${string/%substring/replace} 使用replace 代替 在string后缀中匹配的substring
原始内容可使用 man bash 查看
相关文章推荐
- linux之基础shell脚本编程4 字符串操作,变量赋值,配置用户环境
- linux之基础shell脚本编程1 基础变量赋值
- Shell 编程9(高级变量)
- Understanding Unix/Linux Programming 笔记:chapter 9:可编程的shell、shell变量和环境; chapter 10:I/O重定向和管道
- linux 下shell 编程之变量及数学运算
- Linux学习-高级shell脚本编程(一)函数的妙用
- linux----->shell高级编程----grep应用
- 高级shell脚本编程之重定向、环境变量、shell函数、echo命令用法
- Linux脚本(shell)编程(三) 文件操作
- Linux脚本(shell)编程(三) 文件操作
- Linux Shell编程(二)--Shell变量及相关操作
- *Linux Shell 高级编程技巧2----shell工具
- *Linux Shell 高级编程技巧3----运行级别脚本介绍
- Linux-C高级编程(1)文件操作(二)
- linux——Shell 脚本基础篇(变量类型,变量操作,定义,运算与逻辑关系)
- *Linux Shell 高级编程技巧4----几个常用的shell脚本例子
- linux基本操作---shell脚本-变量、表达式、日期
- linux----->shell高级编程----sed应用
- Linux-Shell脚本编程-学习-4-Shell编程-操作数字-加减乘除计算
- Linux Bash Shell高级重定向操作--深入了解标准错误输出和标准输出