In bash script, what is the easy way to extract a text pattern from a string?
For example, I want to extract X followed by 2 digits in the end of the string?
In bash script, what is the easy way to extract a text pattern from a string?
For example, I want to extract X followed by 2 digits in the end of the string?
I need to extract the host port from this string: NIC 1 Rule(0): name = guestssh, protocol = tcp, host ip = , host port = 2222, guest ip = , guest port = 22
That string is obtained by using: vboxmanage showvminfo Mojave | grep 'host port', I mean is filtered and I need to extract whatever number be in the host port; in this case is 2222 but it can be different.