How to extract last part of string in bash?

I have this variable:

A="Some variable has value abc.123"

I need to extract this value i.e abc.123. Is this possible in bash?


  • How do you know where the value begins? If it's always the 5th and 6th words, you could use e.g.:

    B=$(echo "$A" | cut -d ' ' -f 5-)

    This uses the cut command to slice out part of the line, using a simple space as the word delimiter.