Suppose I have the string 1:2:3:4:5 and I want to get its last field (5 in this case). How do I do that using Bash? I tried cut, but I
1:2:3:4:5
5
cut
Another way is to reverse before and after cut:
$ echo ab:cd:ef | rev | cut -d: -f1 | rev ef
This makes it very easy to get the last but one field, or any range of fields numbered from the end.