如何提取字符串的一部分? [英] How to extract a part of string?

查看:224
本文介绍了如何提取字符串的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有字符串包含路径

string="toto.titi.1.tata.2.abc.def"

我想提取其中 toto.titi.1.tata.2位于后子串。。但图1和2在这里是例子,可以是其他数目。

I want to extract the substring which is situated after toto.titi.1.tata.2.. but 1 and 2 here are examples and could be other numbers.

在一般:我想提取其中位于 toto.titi后的子字符串[我] .tata [J]

In general: I want to extract the substring which situated after toto.titi.[i].tata.[j]..

[I] [J] 是一个数字

怎么办呢?

推荐答案

您可以使用剪切

 echo $string | cut -f6- -d'.'

这篇关于如何提取字符串的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆