I want to parse the port number that I need from the output of the
docker port command. The
docker port <container-name> command returns output as follows:
15672/tcp -> 0.0.0.0:49187 5672/tcp -> 0.0.0.0:49188 5678/tcp -> 0.0.0.0:49189
So it is either a single port number or 2 port numbers.
Thankfully, in the case that the command spews out 2 port numbers, I always need only the second one displayed. To clarify, in the two examples above, I need to parse out
49189 port values from the output of the
docker port command.
What is the shortest way of achieving this?