You can do this simpy with awk.
set the field separator FS = "/" and $ NF will print the last field of each record.
awk 'BEGIN{FS="/"} {print $NF}' file.txt
or
awk -F/ '{print $NF}' file.txt
Or you can do it with the cut command and unix rev
rev file.txt | cut -d '/' -f1 | rev
source share