Search code examples
linuxshellsedawkash

How to extract a part of string?


I have string contains a path

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

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.

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

[i] and [j] are a numbers

How to do it?


Solution

  • You can use cut

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