linuxbashcut

How to find the last field using 'cut'


Without using sed or awk, only cut, how do I get the last field when the number of fields are unknown or change with every line?


Solution

  • You could try something like this:

    echo 'maps.google.com' | rev | cut -d'.' -f 1 | rev
    

    Explanation