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
If you like python and have an option to install a package, you can use this python utility.
# install pythonp pythonp -m pip install pythonp echo "1:2:3:4:5" | pythonp "l.split(':')[-1]" 5