I seem to have failed at something pretty simple, in bash. I have a string variable that holds the full path to a directory. I\'d like to assign the last two di
I think there's a shorter way using globs, but:
$ DIRNAME='a/b/c/d/e' $ LAST_TWO=$(expr "$DIRNAME" : '.*/\([^/]*/[^/]*\)$') $ echo $LAST_TWO d/e