1.${string:position}
在$string中从位置$position开始提取字串
2.实例
操作字符串样例:string=abc123ABC456xyz
索引下标从0开始 0123456789...........
字符串操作默认从左边开始进行
2.1.提取全部string字符串
命令:
echo ${string:0}
[root@rhel77 ~]# string=abc123ABC456xyz
[root@rhel77 ~]# echo ${string:0}
abc123ABC456xyz
[root@rhel77 ~]#
2.2.从第7位开始,提取string剩余子串
命令:
echo ${string:7}
[root@rhel77 ~]# echo ${string:7}
BC456xyz
[root@rhel77 ~]#
文章介绍了如何在Linux环境中使用shell脚本从字符串的特定位置开始提取子串。示例包括从字符串的起始位置提取全部字符串以及从第7位开始提取剩余部分。这些技巧在处理文本数据时非常实用。
527

被折叠的 条评论
为什么被折叠?



