How to separate the last field of a string in Linux

There are many different ways to cut the last field of a string in Linux.

Method1: Using 'cut' command

#echo 'www.techies-world.com' | rev | cut -d'.' -f 1 | rev

Method2: Using grep command

#echo 'www.techies-world.com' | grep -o '[^.]*$'

Method3: Using awk command

#echo 'www.techies-world.com' | awk -F. '{print $(NF)}'

 

Leave a Reply

Your email address will not be published. Required fields are marked *