UNIX Get Last Field with Cut
UNIX command cut
can cut Nth field from input. But it doesn’t support last Nth field.
Stack Overflow again gives nice answers. rev
would be usefule here. To get the last field from current path:
pwd | rev | cut -d'/' -f1 | rev