How to get basename of parent's parent's directory name in shell?

Viewed 10373

I want to get hold of the basename of the parent directory of the parent directory of the current directory in a shell script.

For example:

$ pwd
/home/tmp/terminal/env/1239754/control/state
$

I want to get this - 1239754.

3 Answers
Related