美文网首页
Linux 字符串切片

Linux 字符串切片

作者: 云养江停 | 来源:发表于2021-12-06 11:07 被阅读0次

利用 : 进行截取

给定变量 var="https://www.163.com/index.html"

echo ${var:8}从开头第9个字符开始到结尾,结果:www.163.com/index.html

从开头匹配取5个字符,${var:0:5}结果:https

从右边第4个字符开始到结尾 ,echo ${var:0-4}, 结果:html

从右边第10个字符开始取5个字符,echo ${var:0-10:5},结果: index

相关文章

网友评论

      本文标题:Linux 字符串切片

      本文链接:https://www.haomeiwen.com/subject/pdugxrtx.html