I would like to remove any suffix from a string starting with the last .svc. . As a example:
abc.svc.cluster.local => abc
abc.svc.svc.cluster.local => abc.svc
abc.txt => abc.txt
abc.svc.xyz.svc.zzz => abc.svc.xyz
svc.xxx => svc.xxx (missing . before svc)
If I was doing this is Go, I would find the last index of substring .svc. and then trim from that index.
How do I do this in bash? Thanks.