In shell (not Bash) I have a string like this that I want to parse:
stringhere/morestring!99
After parsing, I want to keep the 99
at the end, and throw away the rest of the string.
The substring that needs to be kept will not always be two characters long. It will be one or more digits, from the !
to either the end of string, or a ,
.
Example input/output:
In: stringhere/morestring!99
Out: 99
In: string/more!99,string/more!98,string/more!97
Out: 99
cut
sounds like the obvious thing to use, except for the !
in the middle of the string.
Is there an easy way to do this? Would awk
be better?