shell字符串索引
2017-02-01 19:49
507 查看
shell中的字符串索引一会从0开始,一会从1开始,见例子:
输出如下:
#!/bin/bash string="hello world" length=${#string} echo "string is \""$string"\"" echo "length is $length" index=`expr index "$string" 'o'` echo "index of 'o' is $index" substring=${string:$index} echo "substring begins from index $index is \""$substring"\"" echo "shit happens" echo exit 0
输出如下:
相关文章推荐
- 【Linux】在Linux下运行shell脚本和python文件
- HBase Shell 基本操作
- ADB详解
- linux 建立反向shell
- ADB shell出现error:device offline提示
- 基于Linux的Shell脚本合集链接(github链接)
- 第7章 进程关系(5)_贯穿案例2:mini shell(2)
- Git Bash切换目录失败及修改默认启动路径的操作
- Shell排序
- Azure 基础:用 PowerShell 自动发布 CloudServices
- deamon守护进程
- Git Bash 不能输入中文的简单解决办法
- [9] Window PowerShell DSC 学习系列----错误诊断和分析
- shell学习总结(1-4)
- shell学习总结(5)
- shell学习总结(6)
- PowerShell的学习笔记(1)
- 【Python】webshell扫描初始版本+源码分析
- 使用PSExec时Access is denied 的解决方案
- Azure 基础:用 PowerShell 自动登录