Answers for "string separate by , get last"

1

split and get last

Use rev command altogether with cut command as follows:
echo "a1 a2 a3 a4 a5" | rev | cut -d ' ' -f '1' | rev
#rev reverses string, then you cut from 2th field to end and reverse back
Posted by: Guest on November-10-2020
0

get last string separated by /

String str = "www.anywebsite.com/folder/subfolder/directory";
int index = str.lastIndexOf('/');
String lastString = str.substring(index +1);
Posted by: Guest on May-05-2021

Code answers related to "string separate by , get last"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language